Re: what problem in this sql
| From: | Joel Colombo | Date: | Wed, 12 Mar 2003 09:45:33 +0000 |
| Subject: | Re: what problem in this sql | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-139248@lists.php.net to get a copy of this message | ||
when using multiple tables u must specify where the fields u want are coming
from too.
also the first piece of your WHERE has contdata NOT cont_data.
i just slapped the cont_data.* to all your field names u may want those
fields from different tables
SELECT cont_data.type_id, cont_data.type_name, cont_data.cont_id,
cont_data.type_id, cont_data.cont_title, cont_data.cat_id,
cont_data.cat_name
FROM cont_data, cont_cats, cont_types
WHERE contdata.cont_id = $cont_id
AND cont_data.type_id = cont_types.type_id
AND cont_data.cat_id = cont_cats.cat_id
just remember when pointing to more then 1 table in FROM. u must always
specify where u are selecting from as well.... unless u SELECT * FROM t1,
t2... that will work or SELECT t1.*, t2.field_a, t2.field_c... works also.
Joel Colombo
"Alawi" <albaity@yahoo.com> wrote in message
news:20030312092215.64432.qmail@web10010.mail.yahoo.com...
> SELECT type_id, type_name, cont_id, type_id, cont_title, cat_id,
cat_name
> FROM cont_data, cont_cats, cont_types
> WHERE contdata.cont_id = $cont_id
> AND cont_data.type_id = cont_types.type_id
> AND cont_data.cat_id = cont_cats.cat_id
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Web Hosting - establish your business online