?
Solved

what sql statement do I use?

Posted on 2003-03-26
4
Medium Priority
?
143 Views
Last Modified: 2010-04-01
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
0
Comment
Question by:brasspath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 8214633
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
 

Author Comment

by:brasspath
ID: 8214670
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
 
LVL 2

Accepted Solution

by:
amit_chauhan earned 300 total points
ID: 8214970
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
 

Author Comment

by:brasspath
ID: 8214977
I finally got it to work.  

Thanks
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question