Jump to content


Photo

SQL HAVE in statement


  • Please log in to reply
2 replies to this topic

#1 tecdesign

tecdesign
  • Members
  • PipPipPip
  • Advanced Member
  • 33 posts

Posted 24 April 2006 - 10:03 PM

ok here is the sql statement

SELECT * FROM `topics` WHERE `topicarea` == general HAVE `topicid` >all(select `topicid` from `topics')

What I am trying to say is that the topicarea is general and topicid as the greatest where in my php I will use have the greatest topic id minus $i which will be inside a while loop.

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,022 posts

Posted 24 April 2006 - 10:11 PM


SELECT * FROM `topics` 
WHERE `topicarea` = 'general' 
ORDER BY topicid DESC 
LIMIT 1;

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 sanfly

sanfly
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 24 April 2006 - 10:18 PM

By the way, i believe the correct syntax is HAVING, not HAVE

[a href=\"http://dev.mysql.com/doc/refman/5.0/en/select.html\" target=\"_blank\"]MYSQL SELECT SYNTAX[/a]
If you're not part of the solution, you're part of the precipitate




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users