Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 29th, 2004, 12:50 PM
Authorized User
 
Join Date: Oct 2003
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default sql & join tables & find a field in multiple table

Hi folks,

I'm trying to search for a link in multiple tables in my database and update that link on the web form at once if found. I have trouble with the logic of running through all the tables to find and display it on the form. Would you please guide me how to do it!

table 1:

field name data
*****************************
bookType history
location aaa
bookName American history
id 1
link http://www.yahoo.com

table 2:
/////////////////////////////////////////////////
field name data
******************************************
bookType history
location bbbbb
bookName Mexican history
id 2
link http://www.yahoo.com

/////////////////////////////////////////////////////////////////////
Thanks so much

td



Reply With Quote
  #2 (permalink)  
Old January 29th, 2004, 02:07 PM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Location: Clarksville, TN, USA.
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Do a union query to return all rows from all tables containing that link, the primary key to the table and a calculated field with the table name. Then use that result set to update your tables with a loop.



Sal
Reply With Quote
  #3 (permalink)  
Old January 29th, 2004, 06:18 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I guess a union query would work, but I can't help but ask, WHY why WHY WHY Why whY WHY do you have two separate tables that store the same type of data?


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
Reply


Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Crystal Report & VB6 & SQL Server wlho VB How-To 2 June 5th, 2013 01:58 AM
SQL statement that includes LEFT & RIGHT JOIN in callagga SQL Language 13 June 9th, 2008 02:30 AM
find multiple values from a table field raaj Beginning PHP 0 September 17th, 2007 03:51 AM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 04:41 PM
update table (SQL & DataSet) melvik ADO.NET 1 July 24th, 2003 04:40 PM



All times are GMT -4. The time now is 02:34 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.