Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 29th, 2004, 01:50 PM
Authorized User
Join Date: Oct 2003
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


Old January 29th, 2004, 03:07 PM
sal sal is offline
Friend of Wrox
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts

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.

Old January 29th, 2004, 07:18 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts

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,


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 05:41 PM
update table (SQL & DataSet) melvik ADO.NET 1 July 24th, 2003 04:40 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.