0% found this document useful (0 votes)
136 views

ERROR 1064 (42000) : You Have An Error in Your SQL Syntax Check The Manual That

The document contains the SQL commands and output from interacting with a MySQL database. It shows creating views and tables, inserting and updating data, joining tables, aggregating data using group functions and more. Various tables like pets, pets1, student_courses etc are created, queried and manipulated.

Uploaded by

Shanthini Kaur
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
136 views

ERROR 1064 (42000) : You Have An Error in Your SQL Syntax Check The Manual That

The document contains the SQL commands and output from interacting with a MySQL database. It shows creating views and tables, inserting and updating data, joining tables, aggregating data using group functions and more. Various tables like pets, pets1, student_courses etc are created, queried and manipulated.

Uploaded by

Shanthini Kaur
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that

corresponds to your MySQL server version for the right syntax to use near 'l' at
line 1
mysql> update pets1 set gender='m' where gender='f';

Query OK, 1 row affected (0.03 sec)


Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from pet_view;


+-------+--------+---------+--------+------+
| name | owner | species | gender | DOB |
+-------+--------+---------+--------+------+
| snowy | tintin | pom

|m

| NULL |

| tommy | henry | apso | m


| test | test | apso | m

| NULL |

| NULL |

+-------+--------+---------+--------+------+
3 rows in set (0.00 sec)

mysql> drop view pet_view;


Query OK, 0 rows affected (0.00 sec)

mysql> show tables;


+---------------------+

| Tables_in_univ_db |
+---------------------+
| course_details

| customer

| customer_2

| invoice

| lecturer_attendance |
| lecturer_courses |
| lecturer_profile |
| lecturer_profile1 |
| login_detail
| pets
| pets1

|
|
|

| player2

| std_fees

| std_fees1

| std_fees2

| student_attd

| student_courses
| student_profile
| test_alt
| try

|
|

|
|

+---------------------+
20 rows in set (0.02 sec)

mysql> select * from pets;


+--------+---------+----------+--------+------------+
| name | owner | species | gender | DOB

+--------+---------+----------+--------+------------+
| snowy | tintin | pom

|m

| NULL

| tommy | henry | apso

|m

| NULL

| snowy2 | tintin1 | pom

|m

| NULL

| devil | phantom | alsatian | m

| 2009-09-10 |

+--------+---------+----------+--------+------------+
4 rows in set (0.00 sec)

mysql> select * from student_courses;


+-------------+------------+-----------+
| StdCourseId | Student_Id | Course_Id |
+-------------+------------+-----------+
|

1|

1001 |

1|

3|

1001 |

3|

4|

1001 |

4|

5|

1001 |

6|

6|

1002 |

1|

7|

1002 |

3|

8|

1002 |

4|

10 |

1003 |

1|

11 |

1003 |

3|

12 |

1003 |

4|

13 |

1003 |

6|

+-------------+------------+-----------+
11 rows in set (0.00 sec)

mysql> select student_id from student_courses group by student_id;


+------------+
| student_id |
+------------+
|

1001 |

1002 |

1003 |

+------------+
3 rows in set (0.00 sec)

mysql> select student_id,count(*) from student_courses group by student_id;


+------------+----------+
| student_id | count(*) |
+------------+----------+
|

1001 |

4|

1002 |

3|

1003 |

4|

+------------+----------+

3 rows in set (0.00 sec)

mysql> select * from student_attd;


+---------+------------+------------+---------+
| attd_id | Student_id | attd_date | present |
+---------+------------+------------+---------+
|

1|

1001 | 2015-03-12 | y

2|

1001 | 2015-03-13 | y

3|

1001 | 2015-03-14 | n

5|

1003 | 2015-03-14 | y

6|

1004 | 2015-03-14 | y

43 |

1002 | 2015-03-14 | y

+---------+------------+------------+---------+
6 rows in set (0.02 sec)

mysql> select student_id,count(*) from student_attd group by student_id;


+------------+----------+
| student_id | count(*) |

+------------+----------+
|

1001 |

3|

1002 |

1|

1003 |

1|

1004 |

1|

+------------+----------+
4 rows in set (0.00 sec)

mysql> select student_id,count(*) from student_courses group by student_id;


+------------+----------+
| student_id | count(*) |
+------------+----------+
|

1001 |

4|

1002 |

3|

1003 |

4|

+------------+----------+
3 rows in set (0.00 sec)

mysql> select student_id,group_concat(course_id) from student_courses group by s


tudent_id;
+------------+-------------------------+
| student_id | group_concat(course_id) |
+------------+-------------------------+
|

1001 | 1,3,4,6

1002 | 1,3,4

1003 | 1,3,4,6

|
|
|

+------------+-------------------------+
3 rows in set (0.00 sec)

mysql> select course_id,group_concat(student_id) from student_courses group by c


ourse_id;
+-----------+--------------------------+
| course_id | group_concat(student_id) |
+-----------+--------------------------+
|

1 | 1001,1002,1003

3 | 1001,1002,1003

4 | 1001,1002,1003

6 | 1001,1003

|
|

+-----------+--------------------------+
4 rows in set (0.00 sec)

mysql> select course_details.course_code,group_concat(student_courses.student_id


) from course_details,student_courses where course_details.course_id=student_cou
rses.course_id group by course_details.course_code;
+-------------+------------------------------------------+
| course_code | group_concat(student_courses.student_id) |
+-------------+------------------------------------------+
| DBMS

| 1001,1002,1003

| EAC11

| 1001,1002,1003

| Mat
| SAD

| 1001,1003
| 1001,1002,1003

|
|

+-------------+------------------------------------------+
4 rows in set (0.00 sec)

mysql> select course_details.course_code,group_concat(student_profile.student_na


me) from course_details,student_courses,student_profile where student_proifle.st
udent_id=student_courses.student_id and course_details.course_id=student_courses
.course_id group by course_details.course_code;
ERROR 1054 (42S22): Unknown column 'student_proifle.student_id' in 'where clause
'
mysql> select course_details.course_code,group_concat(student_profile.student_na
me) from course_details,student_courses,student_profile where student_profile.st
udent_id=student_courses.student_id and course_details.course_id=student_courses
.course_id group by course_details.course_code;
+-------------+--------------------------------------------+
| course_code | group_concat(student_profile.student_name) |
+-------------+--------------------------------------------+
| DBMS

| Rani,Darshini,Vicky

| EAC11

| Rani,Darshini,Vicky

| Mat
| SAD

| Rani,Darshini
| Vicky,Rani,Darshini

|
|

+-------------+--------------------------------------------+

4 rows in set (0.00 sec)

mysql> select course_id,group_concat(student_id) from student_courses group by c


ourse_id;
+-----------+--------------------------+
| course_id | group_concat(student_id) |
+-----------+--------------------------+
|

1 | 1001,1002,1003

3 | 1001,1002,1003

4 | 1001,1002,1003

6 | 1001,1003

+-----------+--------------------------+
4 rows in set (0.00 sec)

mysql> select course_id,group_concat(student_id) from student_courses group by c


ourse_id having course_id=1;
+-----------+--------------------------+
| course_id | group_concat(student_id) |

+-----------+--------------------------+
|

1 | 1001,1002,1003

+-----------+--------------------------+
1 row in set (0.09 sec)

mysql> show tables;


+---------------------+
| Tables_in_univ_db |
+---------------------+
| course_details

| customer

| customer_2
| invoice

|
|

| lecturer_attendance |
| lecturer_courses |
| lecturer_profile |
| lecturer_profile1 |
| login_detail

| pets

| pets1

| player2

| std_fees

| std_fees1

| std_fees2

| student_attd

| student_courses
| student_profile
| test_alt
| try

|
|

|
|

+---------------------+
20 rows in set (0.01 sec)

mysql> select * from pets;


+--------+---------+----------+--------+------------+
| name | owner | species | gender | DOB

+--------+---------+----------+--------+------------+

| snowy | tintin | pom

|m

| NULL

| tommy | henry | apso

|m

| NULL

| snowy2 | tintin1 | pom

|m

| NULL

| devil | phantom | alsatian | m

| 2009-09-10 |

+--------+---------+----------+--------+------------+
4 rows in set (0.00 sec)

mysql> select * from pets1;


+-------+--------+---------+--------+------+
| name | owner | species | gender | DOB |
+-------+--------+---------+--------+------+
| snowy | tintin | pom

|m

| NULL |

| tommy | henry | apso | m


| test | test | apso | m

| NULL |

| NULL |

+-------+--------+---------+--------+------+
3 rows in set (0.00 sec)

mysql> select * from pets union select * from pets1;

+--------+---------+----------+--------+------------+
| name | owner | species | gender | DOB

+--------+---------+----------+--------+------------+
| snowy | tintin | pom

|m

| NULL

| tommy | henry | apso

|m

| NULL

| snowy2 | tintin1 | pom

|m

| NULL

| devil | phantom | alsatian | m


| test | test

| apso

|m

| 2009-09-10 |

| NULL

+--------+---------+----------+--------+------------+
5 rows in set (0.00 sec)

mysql> select * from pets union all select * from pets1;


+--------+---------+----------+--------+------------+
| name | owner | species | gender | DOB

+--------+---------+----------+--------+------------+
| snowy | tintin | pom

|m

| NULL

| tommy | henry | apso

|m

| NULL

| snowy2 | tintin1 | pom

|m

| NULL

| devil | phantom | alsatian | m


| snowy | tintin | pom

|m

| tommy | henry | apso


| test | test

| apso

| NULL

|m

|m

| 2009-09-10 |
|

| NULL

| NULL

+--------+---------+----------+--------+------------+
7 rows in set (0.00 sec)

mysql> select * from pets where pets.name in (select name from pets1);
+-------+--------+---------+--------+------+
| name | owner | species | gender | DOB |
+-------+--------+---------+--------+------+
| snowy | tintin | pom

|m

| tommy | henry | apso | m

| NULL |
| NULL |

+-------+--------+---------+--------+------+
2 rows in set (0.03 sec)

mysql> select * from pets where pets.name not in (select name from pets1);
+--------+---------+----------+--------+------------+

| name | owner | species | gender | DOB

+--------+---------+----------+--------+------------+
| snowy2 | tintin1 | pom

|m

| devil | phantom | alsatian | m

| NULL

| 2009-09-10 |

+--------+---------+----------+--------+------------+
2 rows in set (0.00 sec)

mysql>

You might also like