0

anybody can solve my php syntax problem?

$sql = "SELECT entries.*, catagories.cat FROM entries, catagories
WHERE entries.cat_id = catagories.id
ORDER BY dateposted DESC
LIMIT 1;";
4
Contributors
8
Replies
10
Views
5 Years
Discussion Span
Last Post by fobos
0

Is this everything ? What error do you get ?

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 BY dateposted' at line 1 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 BY dateposted' at line 1

0

You are missing your join functionality (not sure what where clause you want to use or which table dateposted belongs to):

$sql = "SELECT entries.*, catagories.cat FROM entries INNER JOIN catagories
ON entries.cat_id = catagories.id
ORDER BY entries.dateposted DESC
LIMIT 1;";
0

You need to specify which table `dateposted` belongs to. My guess is that it is used in both.

$sql = "SELECT entries.*, catagories.cat 
        FROM entries, catagories
        WHERE entries.cat_id = catagories.id
        ORDER BY entries.dateposted DESC
        LIMIT 1";

@simplepixie: Both queries do the same thing.

Edited by pritaeas: n/a

0

Sorry, it is just the way I code so I automatically put it in and you are correct I could have just amended the ORDER BY

0

shailu.thakre, i dont know if your using mulitple accounts for this solution, DONT DOUBLE POST. This was in MySQL forum, but under a different name.

$sql = "SELECT entries.*, catagories.cat
FROM entries, catagories
WHERE entries.cat_id = catagories.id
ORDER BY dateposted DESC
LIMIT 1;";

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.