SELECT * FROM sw_credit s, tblcustomer c, WHERE s.credit > 0 AND s.customer_id=c.id ORDER BY s.cid DESC Error Code : 1064 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 'WHERE s.credit > 0 AND s.customer_id=c.id ORDER BY s.cid' at line 1 Please help me to correct this query.
SELECT * FROM sw_credit s, tblcustomer c, needs to be SELECT * FROM sw_credit s, tblcustomer c The extra comma was killing it.
The error is because you have an extra comma after "FROM sw_credit s, tblcustomer c" You should be aware that "SELECT *" are rarely the optimal way to go. Consider only SELECTing the columns you need for maximum speed.
I wouldn't say that speed is the factor which shd decide against SELECT *. The factor should be space. SELECT * takes up more data, the bulk of which is not necessary.
I should translate, so there is no confusion. Invoking an unqualified SELECT * returns all columns whether the client application needs the data or not. This approach is not recommended, explicitly name columns in SELECT statements.
consider the scenario.. a table has id, name, demographic details like address and stuff, essays written by the member and some other data.. a query needs to be written to pull all the names in the table. if u use SELECT *, you will be collecting 1000 folds the data which you actually require. So the real optimization happens not in savings in terms of time, but in terms of data (space). server's ram or laptop's ram.. doesn't matter.. if we store data which is not necessary there the space available for other applications will be limited and thus impacting the overall response time..
^ I agree. If you've got a lot of people on your site, explicitly naming the rows you want returned will make it immensely quicker then if you just go "SELECT *"
The laptop's RAM? The query isn't sent to to the end users, it is executed on the server and then the *RESULTS* may or may not be sent to the user. You honestly don't know what you're talking about...