Jump to content


Photo

searching multiple tables and fields


  • Please log in to reply
5 replies to this topic

#1 deejay

deejay
  • New Members
  • Pip
  • Newbie
  • 6 posts
  • LocationBournemouth, UK

Posted 04 April 2003 - 02:19 PM

I realise that this subject has already many post on it, its just I cant seem to get my head around it :?

i have a table called \'cctvcity\' and inside that tables called \'products\', \'product_pages\', \'products_attributes\' and \'products_description\'. Say for example if I want to search for my keyword in the \'title\' or \'main_desc\' field of \'product_pages\' then what is wrong with this code.

<?php
\"SELECT *
          FROM cctvcity.products,cctvcity.product_pages,cctvcity.products_attributes,cctvcity.products_description
          WHERE product_pages.title LIKE \'%$search_keyword%\' OR product_pages.main_desc LIKE \'%$search_keyword%\' ORDER BY ASC \";
?>

thank you for any light you may be able to throw on this.

Deej

#2 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 04 April 2003 - 02:24 PM

Now ur quesry looks fine

U havent said much about the error or the output u get using the statement?

can u tell us more about it!!
Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#3 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 04 April 2003 - 02:37 PM

SELECT *
FROM cctvcity.products,cctvcity.product_pages,cctvcity.products_attributes,cctvcity.products_description
WHERE product_pages.title LIKE \'%$search_keyword%\' OR product_pages.main_desc LIKE \'%$search_keyword%\' ORDER BY

give ur field name here

ASC \";
Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#4 deejay

deejay
  • New Members
  • Pip
  • Newbie
  • 6 posts
  • LocationBournemouth, UK

Posted 04 April 2003 - 03:01 PM

sorry,

it fails on \'\'error making query\'

$query = \"SELECT *
FROM cctvcity.products,cctvcity.product_pages,cctvcity.products_attributes,cctvcity.products_description
WHERE product_pages.title LIKE \'%$search_keyword%\' OR product_pages.main_desc LIKE \'%$search_keyword%\' ORDER BY ASC \";


$searchResults = mysql_query($query) or die(\'error making query\');



#5 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 04 April 2003 - 03:33 PM

See my posting

U havent given the filed name after

order by \"filed_name\" asc


Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#6 deejay

deejay
  • New Members
  • Pip
  • Newbie
  • 6 posts
  • LocationBournemouth, UK

Posted 04 April 2003 - 03:50 PM

:oops: how much of an idiot do i feel.


cheers mate, sorted now.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users