Jump to content


Photo

**SOLVED** help please .. sql statement


  • Please log in to reply
2 replies to this topic

#1 n8w

n8w
  • Members
  • PipPipPip
  • Advanced Member
  • 123 posts

Posted 17 March 2006 - 05:26 AM

I don't think this is a join but I'm not sure how to write it.
I need help writing this sql statement

I have two similar tables
articles
audio_articles

I want to return all the records from both tables where
articles - return the field (article_id) where ( feature=t and live_date>today )
audio_articles (id) AS article_id where ( s_front=t and s_date>today )

#2 Barand

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

Posted 17 March 2006 - 07:51 AM

Sounds like you need a UNION

SELECT article_id FROM articles  WHERE ( feature='t' AND live_date>CURDATE() )
UNION
SELECT  id AS article_id FROM audio_articles WHERE ( s_front='t' and s_date>CURDATE())

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 n8w

n8w
  • Members
  • PipPipPip
  • Advanced Member
  • 123 posts

Posted 17 March 2006 - 12:44 PM

[!--quoteo(post=355866:date=Mar 17 2006, 04:51 AM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Mar 17 2006, 04:51 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Sounds like you need a UNION

SELECT article_id FROM articles  WHERE ( feature='t' AND live_date>CURDATE() )
UNION
SELECT  id AS article_id FROM audio_articles WHERE ( s_front='t' and s_date>CURDATE())
[/quote]

Hey Barand .. you are awesome! thanks!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users