Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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 'order set custid='4',catid='1', proid='2',quantity='14',totalbill='1400', ' at line 1]


SQL
insert into order set custid='$custid',catid='$catid',
proid='$proid',quantity='$quantity',totalbill='$totalbill',
deldate='$var_date',orderstatus='$orderstatus
Posted
Updated 2-Mar-14 7:11am
v2
Comments
Richard MacCutchan 2-Mar-14 13:02pm    
Is this a homework question? If so then please do what you are asked.
zunisheikh 2-Mar-14 13:26pm    
no no i am a software developer
bt its my start
thats y i am stuck

1 solution

because order is a keyword. convert your statement into that:

SQL
insert into `order` set custid='$custid',catid='$catid',
proid='$proid',quantity='$quantity',totalbill='$totalbill',
deldate='$var_date',orderstatus='$orderstatus
 
Share this answer
 
Comments
zunisheikh 2-Mar-14 13:27pm    
custid catid proid orderid quantity deldate totalbill orderstatus deladdress
Edit Delete
1 1 1 1 5 2014-02-04 200 avaliable g-10
its shows customer id product id and category id bt i want here name of customer ,category and product
Vedat Ozan Oner 2-Mar-14 13:34pm    
you can join with other tables. http://dev.mysql.com/doc/refman/5.0/en/join.html
zunisheikh 2-Mar-14 14:24pm    
SELECT ord.orderid,cus.custid,cus.custname,cat.catid,cat.catname,pro.proid,pro.proname from `order` as ord inner join`customer` as cus on cus.custid=ord.custid inner join `category` as cat on cat.catid=ord.catid inner join `product` as pro on pro.proid=ord.proid

yes i did this bt still it select no record.what should i do
Vedat Ozan Oner 3-Mar-14 1:44am    
if your db is properly designed (ie. primary keys, foreign keys etc), then this query should work. But I think one of the tables has no row, therefore your 'inner join's returns no row. check your table relations, keys and try to select from each table one by one. after you find the table without any record, you can fix it. And more important point, I advice you to read mysql reference carefully to understand what joins and other relational db concepts. you should know these things as a software developer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900