Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 144
  • Last Modified:

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
0
brasspath
Asked:
brasspath
  • 2
1 Solution
 
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
 
brasspathAuthor Commented:
I finally got it to work.  

Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now