Question

I have the follow query selecting stuff from a database:

mysql_query("SELECT * FROM categories order by id desc EXCEPT 
             WHERE id = $post_id") 
or die(mysql_error());

What I want to do is select all the columns in the "category" table, order them by id descending except where the column "id" equals the variable $post_id.

However, this does not work. I'm relatively new to this sort of stuff so could you guys give me a pointer in the right direction? I'd really appreciate it.

Thanks!

Was it helpful?

Solution

try this instead:

SELECT * FROM categories WHERE id != $post_id
order by id desc 

/* except = not equal */
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top