| 100MB Hosting with Free Domain Cpanel hosting & domain for $19.95/yr. |
Cpanel Free Hosting Packages upto 1GB space with PHP/ASP/Perl/Ruby & MySQL |
1month free trail hosting
no payment for 1st month, choose any monthly or yearly plan afterwards |
|
| Threaded Mode | Linear Mode |
Query Problem
|
|
Post: #1
|
|||
|
|||
|
Query Problem
Anyone know what I'm doing wrong here:
Quote:SELECT * FROM messages WHERE to = 1 ORDER BY time DESC LIMIT 0, 20 That returns: Quote: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 'to = 1 ORDER BY time DESC LIMIT 0, 20' at line 1 "time" is of type DATETIME. "to" is of type MEDIUMINT. It works if I get rid of "WHERE to = 1" which I need (it's a PM system...you don't want everyone to read your PMs!). What do I do? Use subqueries? (not sure what I'd do for that) Thanks for any help given. EDIT: I've also tried doing WHERE to = "1" but that doesn't work either.
All moderations in indigo.
http://www.caglow.com - The open astronomy force. http://aciqra.caglow.com - Free desktop planetarium. http://i.caglow.com - Scripting language. ~North to the future |
|||
|
Post: #2
|
|||
|
|||
|
RE: Query Problem
Figured out the problem...had to surround time with`` because TIME is a reserved word in MySQL.
All moderations in indigo.
http://www.caglow.com - The open astronomy force. http://aciqra.caglow.com - Free desktop planetarium. http://i.caglow.com - Scripting language. ~North to the future |
|||
|
Post: #3
|
|||
|
|||
|
RE: Query Problem
yes was about to tell you, it's a good idea to surround each database/table names with ``, it'll avoid lot of errors
|
|||
|
Post: #4
|
|||
|
|||
|
RE: Query Problem
`` is mainly for tables or columns that might have bits that break, such as space _ or -, also the windows word ` is different to every other one so dont copy and paste, causes alot of peole issues like that
|
|||
|
Post: #5
|
|||
|
|||
|
RE: Query Problem
To should add ` both side:`To`
|
|||
|
Post: #6
|
|||
|
|||
|
RE: Query Problem
and selecting all (SELECT * FROM) is bad habbit, try only selecting stuff you need
|
|||
|
Post: #7
|
|||
|
|||
|
RE: Query Problem
SELECT * FROM `messages` WHERE `to` = 1 ORDER BY `time` DESC LIMIT 0, 20
|
|||
|
Post: #8
|
|||
|
|||
|
RE: Query Problem
or without ''
SELECT * FROM messages WHERE to = 1 ORDER BY time DESC LIMIT 0, 20 |
|||
|
« Next Oldest | Next Newest »
|



