OK I have a question worth a few points for you SQL experts out there
i have a query as follows
$search="United_States";
==========================
=====
$check_customer_query = db_query("
SELECT
customers_listing_dir.cust
omers_list
dir_url,
customers_listing_dir.cust
omers_list
ing_name,
customers_photo.photo_url,
customers_meta.meta_descri
ption
FROM " . TABLE_CUSTOMERS_PHOTO . "," . TABLE_CUSTOMERS_LISTING_DI
R . "," . TABLE_CUSTOMERS_META . "
WHERE
customers_listing_dir.cust
omers_list
dir_id = customers_photo.customers_
listdir_id
AND
customers_listing_dir.cust
omers_list
dir_id = customers_meta.customers_l
istdir_id
AND
customers_listing_dir.list
ing_approv
ed='1'
AND
customers_listing_dir.cust
omers_list
vr_name='"
.$search."
'
ORDER BY customers_listing_dir.time
_date_adde
d DESC
");
==========================
==========
==
The problem is it only returns 1 record and there's definitly more then one, basicly i need
* records containing this data
--------------------------
----------
----------
------
customers_listing_dir.cust
omers_list
dir_url,
customers_listing_dir.cust
omers_list
ing_name,
customers_photo.photo_url,
customers_meta.meta_descri
ption
--------------------------
----------
----------
------
from 3 diffrent tables
--------------------------
----------
----------
--------
FROM " . TABLE_CUSTOMERS_PHOTO . "," . TABLE_CUSTOMERS_LISTING_DI
R . "," . TABLE_CUSTOMERS_META . "
--------------------------
----------
----------
--------
--------------------------
----------
----------
----------
----------
----------
------
WHERE these three tables return the related data rows for (customers_listing_dir.cus
tomers_lis
tdir_id )
FROM " . TABLE_CUSTOMERS_PHOTO . "," . TABLE_CUSTOMERS_LISTING_DI
R . "," . TABLE_CUSTOMERS_META . "
--------------------------
----------
----------
----------
----------
----------
----
AND
customers_listing_dir.list
ing_approv
ed='1'
AND
customers_listing_dir.cust
omers_list
vr_name='"
.$search."
' // where $search is the defined variable above//
-----------------------
The problem is , it returns only 1 record when there is many, under the same listdir_id , does someone know how to construct a more efficent query to get related data from 3 diffrent tables upon a search term and approval condition.
Thanks for your help in advance
Sonny
Start Free Trial