Click to See Complete Forum and Search --> : [RESOLVED] sql problem


raj_2006
09-27-2006, 02:15 PM
Hi

this is a continuation from my previous thread...I wish to continue from that thread but i have marked that one with resolved....anyway

I have a product table where 4 records are there.

pid(product id) is the primary key,autoincremental and cid is the category id.

cid pid
20 1
20 2
20 3
20 4

In another table named special there are 3 records.But in this table there is no primary key.here is also the same pid as in product table.

pid discount
1 10
2 20
3 30

Now i want to show the all products either with discount or without discount
so it will be like this

pid discount
1 10
2 20
3 30
4 no discount //this text i can display.

Now I am writing this query

SELECT * from product LEFT JOIN special on product.pid = special.pid WHERE product.cid = $master_id;

4 rows are displaying but one pid is not showing

its looking like this

pid discount
1 10
2 20
3 30
no discount //this text i can display and here the pid 4 is missing

Can anyone please suggest me what should i do?

Thanks in advance for your co-operation

Raj

chazzy
09-27-2006, 05:52 PM
what do you mean by not displayed? how are you displaying it, just through the command line client or something else?

raj_2006
09-28-2006, 12:08 PM
hi

thanks for your reply...Its solved..

I just altered the sql in this way:

SELECT *,product .pid from product LEFT JOIN special on product.pid = special.pid WHERE product.cid = $master_id;

thanks again........:)

chazzy
09-28-2006, 02:03 PM
i guess this goes back to avoiding using * in queries.