corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » (my)SQL dudes


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author (my)SQL dudes
Dom
Member

Registered: 13th Sep 03
User status: Offline
3rd May 07 at 14:57   View User's Profile U2U Member Reply With Quote

How would you go about doing a multiple search on a number of tables and cols and get x, y, z data?

At the moment, i split the words and then do a query through each one, but it seems to be the slowest method going. How would i go about querying the SQL DB directly to do this? (as im guessing that would be the quickest method?). Or is there a better way?

Cheers for any help
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
3rd May 07 at 15:00   View Garage View User's Profile U2U Member Reply With Quote

mysql(SELECT * FROM column1.table1, column2.table2, column3.table3
WHERE blah blah blah

do an inner join if you want also, make sure your tables have a correct index name that tallies in with your query

[Edited on 03-05-2007 by Steve]
Dom
Member

Registered: 13th Sep 03
User status: Offline
3rd May 07 at 15:08   View User's Profile U2U Member Reply With Quote

yea i can do single searches thats fine, but i want to search on a string - like: frank bob chocolate finger cat.

If you just query that, it matches just that, but im after a search that will go through each word and pull out matches - then display the best ones, relevance etc etc

like i said, at the moment i loop through each word, but there must be a quicker way and its important that its done as quickly as possible as it isn't a little site.

cheers anyways steve.
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
3rd May 07 at 15:16   View Garage View User's Profile U2U Member Reply With Quote

tried using LIKE? with an OR

[Edited on 03-05-2007 by Steve]
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
3rd May 07 at 15:17   View Garage View User's Profile U2U Member Reply With Quote

mysql(SELECT * FROM column1.table1, column2.table2, column3.table3
WHERE column2.word1 = "' . $word1 ."'
OR blah blah

[Edited on 03-05-2007 by Steve]
Dom
Member

Registered: 13th Sep 03
User status: Offline
3rd May 07 at 15:23   View User's Profile U2U Member Reply With Quote

yep used them, alright for basic searches, but im having to search through a few 1000 products, so need something stupidly quick and able to pull out anything that matches. As well as having stats based on that, so they can be sorted - relevance, price etc
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
3rd May 07 at 15:26   View Garage View User's Profile U2U Member Reply With Quote

i think then you need to look at your indexes on your tables to see if they are correct, properly indexed tables should do that kind of search ultra fast
Tim
Site Administrator

Avatar

Registered: 21st Apr 00
User status: Offline
3rd May 07 at 22:00   View Garage View User's Profile U2U Member Reply With Quote

Just create a full-text index on the column(s), then query using MATCH (column) AGAINST (query) (does relevance like the CS search).

Just Google for fulltext mysql...

[Edited on 03-05-2007 by Tim]
Ian
Site Administrator

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Offline
3rd May 07 at 23:18   View Garage View User's Profile U2U Member Reply With Quote

Would be helpful to know table structure and exactly what you want the results to look like, then build some queries.

When that is done perhaps some indexes to speed things up, in addition to the fulltext one if you're using that as Tim suggests.

There are limitations inbuilt in to fulltext the most problematic being the minimum word length but that can be altered. Its far superior to LIKE, especially as you don't need to split the words up so they're not treated as a phrase as you would have to with LIKE.
Dom
Member

Registered: 13th Sep 03
User status: Offline
3rd May 07 at 23:50   View User's Profile U2U Member Reply With Quote

cheers tim and ian, will give it a go

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
website help :( Drew Geek Day 18 1101
30th Nov 04 at 21:26
by Drew
 
Need a good MySQL host Matt H Geek Day 3 1043
14th Feb 05 at 22:08
by John
 
SQL Server Bart Geek Day 1 848
1st Feb 07 at 16:44
by Samls
 
sql/forms builder help - pretty basic really Tantastic Geek Day 6 683
28th Mar 07 at 18:06
by Tantastic
 
XML/PHP Laney Geek Day 6 808
26th Apr 07 at 15:03
by Ian
 

Corsa Sport » Message Board » Off Day » Geek Day » (my)SQL dudes 29 database queries in 0.0111330 seconds