Web Design and Development Forums

Seraching inside all tables

This is a discussion on "Seraching inside all tables" within the MySQL section. This forum, and the thread "Seraching inside all tables are both part of the Databases category.


Go Back   Webforumz.com > Databases > MySQL

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rating: Thread Rating: 1 votes, 5.00 average.
Old Jan 26th, 2008, 15:30   #1 (permalink)
New Member
 
Join Date: Apr 2007
Location: Israel
Age: 16
Posts: 3
Wink Seraching inside all tables

Hi,
I need to find the names of all the tables that have a value in a field.
For example, There are 5 tables: t1, t2, t3, t4, t5
and each one has 6 fieldsm, one of them is f4.
I need the name of all the tables that has "Felix" as a value in the f4 field.

How do I do that?

I basicly need something that will work like this incorrect piece of code:


SELECT * FROM users.* /* users is the database, * meand all tables */ WHERE `name`="Felix"

PHP MySQL.

Thank you.

Last edited by Felixr; Jan 26th, 2008 at 15:33.
Felixr is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 26th, 2008, 15:35   #2 (permalink)
Section Manager - WOTM
Assistant Editor - LZ
 
Jack Franklin's Avatar
 
Join Date: May 2007
Location: Cornwall, England
Posts: 1,101
Blog Entries: 5
Re: Seraching inside all tables

Would:

Code: Select all
SELECT * FROM users WHERE name='Felix'
Not work? Have you tried that? I'm only just starting out with MySQL so I cannot be sure.
__________________
Section Manager (WOTM)

My Weblog & E-Portfolio
Catch me daily on: Twitter | Digg | Flickr
Jack Franklin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 26th, 2008, 23:08   #3 (permalink)
Administrator
 
alexgeek's Avatar
 
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 4,102
Blog Entries: 9
Send a message via MSN to alexgeek
Re: Seraching inside all tables

No Jack, that would only search one table.
__________________
Languages: PHP, mySQL (queries), C#, (X)html, CSS, JS.


alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 27th, 2008, 09:11   #4 (permalink)
Section Manager - WOTM
Assistant Editor - LZ
 
Jack Franklin's Avatar
 
Join Date: May 2007
Location: Cornwall, England
Posts: 1,101
Blog Entries: 5
Re: Seraching inside all tables

Code: Select all
 
(Connect to your db) and then:
 
SELECT * FROM table1, table2, table3, etc (add your tables here) WHERE name='Felix'
So in PHP:
PHP: Select all

$sql "SELECT * FROM table1, table2, etc WHERE name='Felix'";
if (
$sql) {
echo 
'all done';
} else {
echo 
'error';

Try that?

Remembering first you need to connect to the database:
PHP: Select all

# DataBase Settings
$hostname_config "localhost";     # 99% Leave Localhost
$database_config "";   # Database Name
$username_config "";   # Database Username
$password_config "";    # Password 
$conn mysql_connect($hostname_config$username_config$password_config) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db($database_config)or die(mysql_error()); 
__________________
Section Manager (WOTM)

My Weblog & E-Portfolio
Catch me daily on: Twitter | Digg | Flickr

Last edited by Jack Franklin; Jan 27th, 2008 at 09:13.
Jack Franklin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 27th, 2008, 12:55   #5 (permalink)
 
Rakuli's Avatar
 
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 980
Blog Entries: 2
Re: Seraching inside all tables

I think he's asking for a way to get the table name containing the value rather than get the results themselves.

The query might look something like this

Code: Select all
SELECT t1.f4 AS table1, t2.f4 AS table2, t3.f4 AS table3, t4.f4 AS table4, t5.f4 AS table5  
FROM t1 
LEFT JOIN t2 ON (t1.f4=t2.f4) 
LEFT JOIN t3 ON (t2.f4-t3.f4)
LEFT JOIN t4 ON (t3.f4=t4.f4)
LEFT JOIN t5 ON (t4.f4=t5.f4) 
WHERE t1.f4 = 'felix' OR t2.f4 = 'felix' OR t3.f4 = 'felix OR t4.f4 = 'felix' OR t5.f4 = 'felix'
That query above will give alarge result set but basically the columns it returns will be named table1-5 respectively. It's then a matter of checking if any of the rows return have a value of felix under table-15
__________________
Rakuli

Helping you expand your epiphanies:

pen Source of pen Thoughts
Rakuli is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 27th, 2008, 13:08   #6 (permalink)
New Member
 
Join Date: Apr 2007
Location: Israel
Age: 16
Posts: 3
Re: Seraching inside all tables

Thanks, but I meant that there are way to many tables for my to just enter their names...
I need to search inside all of them.
Felixr is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
including inside a function CloudedVision PHP Forum 2 Feb 11th, 2008 00:13
[SOLVED] positioning something inside an image danny322 CSS Forum 3 Dec 5th, 2007 13:36
Media player inside HTML. McAurthur19 HTML Forum 6 Feb 18th, 2007 14:09
a YaBB inside of my layout. need to use it's CSS too jswebdev CSS Forum 0 Sep 29th, 2005 01:07
HTML inside of flash..... courtjester Flash & Multimedia Forum 12 Mar 30th, 2004 12:24



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 04:59.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59