J N
asked on
mysql select multiple tables
Hi,
I want to make a search function on a website and i would like to create a sql query that searches all of my preferred tables in my sql database and see if anything matches. i was thinking that i would have to use wildcards but im not sure how i could accomplish this or even if its possible
the list of my tables are
Home Log out Query window phpMyAdmin documentation Documentation
- bushbase (21)
bb_users
blog
bucket_list
destinations
drinks
events
games
help
music
news
pages
photos
thanks in advance
I want to make a search function on a website and i would like to create a sql query that searches all of my preferred tables in my sql database and see if anything matches. i was thinking that i would have to use wildcards but im not sure how i could accomplish this or even if its possible
the list of my tables are
Home Log out Query window phpMyAdmin documentation Documentation
- bushbase (21)
bb_users
blog
bucket_list
destinations
drinks
events
games
help
music
news
pages
photos
thanks in advance
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
When it comes to "search" Google kind of owns the space. They can build a custom search engine for your site.
https://support.google.com/customsearch/answer/72325?hl=en
I have used Atomz, Freefind, and Wrensoft "Zoom" search with good results, too. My point here is that you do not need to go back in time a dozen years to reinvent the future of web search as it was back then, before modern technology took over. Just use the inventions of others! Many are free and open source and all of them have at least a dozen years (and hundreds of millions of dollars) head-start on anything you can begin building today.
https://support.google.com/customsearch/answer/72325?hl=en
I have used Atomz, Freefind, and Wrensoft "Zoom" search with good results, too. My point here is that you do not need to go back in time a dozen years to reinvent the future of web search as it was back then, before modern technology took over. Just use the inventions of others! Many are free and open source and all of them have at least a dozen years (and hundreds of millions of dollars) head-start on anything you can begin building today.
ASKER
Hi,
Thanks for your responses
1) i have used zoom before but i always have to update it and adjust some of the settings which i do not like.
2) i have looked into google but i was unable to update the styling so i did not like it
i just want to know how i would select multiple tables:
SELECT * FROM table1, table2... WHERE column1, column2, column3 LIKE 'something%' OR field2 LIKE 'something%'
Thanks for your responses
1) i have used zoom before but i always have to update it and adjust some of the settings which i do not like.
2) i have looked into google but i was unable to update the styling so i did not like it
i just want to know how i would select multiple tables:
SELECT * FROM table1, table2... WHERE column1, column2, column3 LIKE 'something%' OR field2 LIKE 'something%'
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@tel2: Good point. A GROUP BY clause may be helpful, too.
ASKER
Hi,
So i made the following SQL
and im not yielding any results
So i made the following SQL
SELECT * FROM blog, bucket_list, destinations, drinks, events, games, help, music, news, pages, photos
WHERE status='active' AND (
title LIKE (:title) OR image LIKE (:image) OR photographer LIKE (:photo) OR date LIKE (:date) OR
author LIKE (:author) OR content LIKE (:content) OR tags LIKE (:tags) OR tagline LIKE (:tagline) OR
category LIKE (:cat) OR location LIKE (:loc) OR city LIKE (:city) OR country LIKE (:country) OR latitude LIKE (:lat) OR
longitude LIKE (:long) OR start_date LIKE (:start) OR fin_date LIKE (:end) OR ingredients LIKE (:item) OR
difficulty LIKE (:bitch) OR occasion LIKE (:occ) OR type LIKE (:type) required_items LIKE (:required) OR
url_link LIKE (:url) OR name LIKE (:name) OR genre LIKE (:genre) OR artist LIKE (:artist) OR personal_desc LIKE
(:desc) OR source_uploader LIKE (:uploader) OR source_description LIKE (:src_desc) OR
header1 LIKE (:header1) OR header2 LIKE (:header2) OR header3 LIKE (:header3) OR header4 LIKE (:header4) OR
header5 LIKE (:header5) OR content_title1 LIKE (:title1) OR content_title2 LIKE (:title2) OR link LIKE (:link) OR
trip LIKE (:trip) )
and im not yielding any results
Array
(
[:title] => %$search_item%
[:image] => %$search_item%
[:photo] => %$search_item%
[:date] => %$search_item%
[:author] => %$search_item%
[:content] => %$search_item%
[:tags] => %$search_item%
[:tagline] => %$search_item%
[:cat] => %$search_item%
[:loc] => %$search_item%
[:city] => %$search_item%
[:country] => %$search_item%
[:lat] => %$search_item%
[:long] => %$search_item%
[:start] => %$search_item%
[:end] => %$search_item%
[:item] => %$search_item%
[:bitch] => %$search_item%
[:occ] => %$search_item%
[:type] => %$search_item%
[:required] => %$search_item%
[:url] => %$search_item%
[:name] => %$search_item%
[:genre] => %$search_item%
[:artist] => %$search_item%
[:desc] => %$search_item%
[:uploader] => %$search_item%
[:src_desc] => %$search_item%
[:header1] => %$search_item%
[:header2] => %$search_item%
[:header3] => %$search_item%
[:header4] => %$search_item%
[:header5] => %$search_item%
[:title1] => %$search_item%
[:title2] => %$search_item%
[:link] => %$search_item%
[:trip] => %$search_item%
)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
a typical SQL query requires field names
e.g.
SELECT field1, field2 FROM anytable WHERE field1 LIKE 'something%' OR field2 LIKE 'something%'
but:
Perhaps you have implemented some full text indexes?
SELECT * FROM anytable WHERE MATCH (title,body) AGAINST ('something')
{edit: it is MySQL}