what sql statement do I use?

Here is my table/field layout:

CATS: CAT_ID(index),CAT_NAME
ADS: AD_ID(index),CAT_ID,AD_DESCRIPTION,AD_APPROVED

There is a one-to-many relationship from CATS table to ADS table on CAT_ID.

What does my SQL query statement need to look like if I want to show all the records where AD_APPROVED is equal to 1.

I want to be able to use all the field names later in the script, so the select statement should capture those.

Thanks in advance.

brasspath
brasspathAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bobbit31Commented:
would this work?

select TC.*, TA.* from CATS TC Inner Join ADS TA ON TA.CAT_ID = TC.CAT_ID WHERE TA.AD_APPROVED = 1
0
brasspathAuthor Commented:
I tried this as my select statement, but it did not work:

"SELECT CATS.*, ADS.* from CATS Inner Join ADS ON ADS.CAT_ID = CATS.CAT_ID WHERE ADS.AD_APPROVED = 1"
0
amit_chauhanCommented:
Hi,
This works for me in Oracle :

SELECT a.*, b.*
FROM cats a, ads b
WHERE a.cat_id = b.cat_id
  AND a.ad_approved = 1


Hope that helps
Thanks
Amit
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brasspathAuthor Commented:
I finally got it to work.  

Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.