Vinod
You might consider something like:
SELECT
p.product_id,
p.category_id,
p.product_name
FROM product p
INNER JOIN category c
ON p.category_id = c.category_id
WHERE
c.category_name LIKE '%a%'
Another consideration - I don't know which database you're using, but
based on your table definition, I suspect you might be using MS Access.
If so (and it's been a long time since I've used Access), it seems that
Access used the astersisk character (*) for a wildcard rather than the
percent sign (%). If so, you might want to change your WHERE condition to
something like:
WHERE c.category_name LIKE "*a*"
Hope this helps.
- Roger Nedel
Nedel Software Solutions
Salt Lake City, UT
rnedel@b...
==========================
> Hi all,
> I am trying to write sql having subquerry as listed below
> My table Steucture is
> --------------------------
> Category table
> --------------------------
> category_id Autoincrement
> category_name varchAR
>
>
> --------------------------
> Product table
> --------------------------
> Product_id Autoincrement
> category_id Forign key to category table
> Product_name varchAR
> select * from product where category_id IN (Select category_id from
> category where category_name like '%a%')
>
> but I am getting this error
>
> select * from product where category_id IN (Select category_id from
> category where category_name like '%a%') You have an error in your SQL
> syntax near 'Select category_id from category where category_name like
> '%a%') ' at line 1
>
> Please help to find where I am getting wrong
>
>
> Vinod Palan
> SatyaNet Solutions Pvt. Ltd.
> ------------------------------------------
> Your Issues, Our Abilities - Lets simplify
> ------------------------------------------
> 27/29 Vanka Mohalla,
> Dr.M.B.Velkar St, Chira Bazaar,
> Mumbai - 400 002, INDIA.
> Phone: 91- 22 - 2089796
> Fax: 91 - 22 - 2086032
> Email: vinod@s...
> http://www.satyanet.com