Results 1 to 5 of 5
Thread: MySQL query problem
Hybrid View
-
01-26-2007, 11:25 PM #1New Member
- Join Date
- Jan 2007
- Posts
- 3
MySQL query problem
Any obvious reason this query does not work as expected? it returns the correct records - but ignores the Order By request:
Code:select distinct sql_calc_found_rows b.*, u.username from sc_users as u, sc_bookmarks as b where b.uid = u.uid and ((b.bstatus = 0) or (b.uid = 1)) and b.uid = 1 ORDER BY b.bDatetime desc
Code:select distinct sql_calc_found_rows b.*, u.username from sc_users as u, sc_tags AS T0, sc_bookmarks as b where b.uid = u.uid and ((b.bstatus = 0) or (b.uid = 1)) and b.uid = 1 AND T0.bid = b.bid ORDER BY b.bDatetime asc
-
01-27-2007, 07:52 AM #2Web Hosting Master
- Join Date
- Mar 2006
- Posts
- 984
select distinct sql_calc_found_rows b.*, u.username from sc_users as u, sc_bookmarks as b
where b.uid = u.uid and ((b.bstatus = 0) or (b.uid = 1)) and b.uid = 1 ORDER BY b.bDatetime desc
Code:SELECT DISTINCT sql_calc_found_rows b.*, u.username FROM sc_bookmarks b LEFT JOIN sc_users u ON (u.uid = b.uid) WHERE ((b.bstatus = 0) OR (b.uid = 1)) AND b.uid = 1 ORDER BY b.bDatetime DESC
-
01-27-2007, 09:15 AM #3New Member
- Join Date
- Jan 2007
- Posts
- 3
Not quite?
I am not much of a SQL expert - do not have the hang of this obviously - as this is throwing an error:
Code:SELECT DISTINCT sql_calc_found_rows b*, u.username FROM sc_bookmarks b LEFT JOIN sc_users u ON (u.uid = b.uid) WHERE ((b.bstatus = 0) OR (b.uid = 1)) AND b.uid = 1 ORDER BY b.bDatetime DESC
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 ' u . username FROM sc_bookmarks b LEFT JOIN sc_users u ON ( u . uid = b . uid ' at line 1
-
01-27-2007, 10:14 AM #4Web Hosting Master
- Join Date
- Mar 2006
- Posts
- 984
In my posted version, there was a dot in it:
Code:b.*, u.username
-
01-27-2007, 10:25 AM #5New Member
- Join Date
- Jan 2007
- Posts
- 3
Well - absolutely right.
I lost the "." somewhere - but when I was studying the code - it was in the forum - with the "." so I did not catch it.
Gracias. Now - I just have to translate it back into the PHP to get it working.