473,473 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Hot to use one mysql query in a second mysql query

Appreciate any help- I want to make a 1st DB query, then I want to feed
those results into a second query - the results of the 2nd query are
then my output. I know it's possible w/a temporary table of the
1st....but I think there's a cleaner way. I tried nested SQL w/MYSQL 4.1
but it hasn't worked. So maybe w/2 sucessive querys w/PHP?? Thanks.
How can I in PHP take a first query eg:

mysql> SELECT balloon_txt.access_no FROM balloon_txt WHERE MATCH
(access_no, recs_txt) AGAINST ('robin');
+------------+
| access_no |
+------------+
| BT-1037.11 |
| BT-2540 |
| BT-1034.06 |
+------------+
3 rows in set (0.00 sec)

and use the result in a 2nd query eg:

mysql> SELECT * FROM balloon_rec WHERE access_no='BT-1034.06';
+------------+--------------------------------------------+----------------+------------+-------------------------------------------------------------------+
| access_no | title | author
| doc_date | elec_access
|
+------------+--------------------------------------------+----------------+------------+-------------------------------------------------------------------+
| BT-1034.06 | Status of Meteorological Sounding Balloons | Robert
Leviton | 1963-12-01 |
http://Databases/Balloon/Data/BT1034.06.pdf |
+------------+--------------------------------------------+----------------+------------+-------------------------------------------------------------------+

So the final result would be three recoeds outputted.
Jul 17 '05 #1
2 1557
"leegold2" <le*****@nospam.net> wrote in message
news:su*****************@nwrddc03.gnilink.net...
How can I in PHP take a first query eg:

mysql> SELECT balloon_txt.access_no FROM balloon_txt WHERE MATCH
(access_no, recs_txt) AGAINST ('robin');

and use the result in a 2nd query eg:

mysql> SELECT * FROM balloon_rec WHERE access_no='BT-1034.06';


I believe this query should work:

SELECT * FROM `balloon_rec` LEFT JOIN `balloon_txt` USING (`access_no`)
WHERE MATCH (`balloon_txt`.`access_no`,`balloon_txt`.`recs_txt `) AGAINST
('robin')

Chris Finke


Jul 17 '05 #2
Christopher Finke wrote:
"leegold2" <le*****@nospam.net> wrote in message
news:su*****************@nwrddc03.gnilink.net...
How can I in PHP take a first query eg:

mysql> SELECT balloon_txt.access_no FROM balloon_txt WHERE MATCH
(access_no, recs_txt) AGAINST ('robin');

and use the result in a 2nd query eg:

mysql> SELECT * FROM balloon_rec WHERE access_no='BT-1034.06';

I believe this query should work:

SELECT * FROM `balloon_rec` LEFT JOIN `balloon_txt` USING (`access_no`)
WHERE MATCH (`balloon_txt`.`access_no`,`balloon_txt`.`recs_txt `) AGAINST
('robin')

Chris Finke


I must thank you - it worked perfectly.
Lee G.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Russ | last post by:
Hi, I'm doing some web development and have mysql (3.23.x) installed to test with (win2k, but I don't think this question is particularly platform specific). I have a reasonably complex query...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
8
by: wlcna | last post by:
mysql v4.0.16: I had been using mysql with innodb and thought that was fine, until i used it for something requiring a few - perhaps slightly involved - joins, and have now seen the performance...
1
by: Good Man | last post by:
Hi there I've noticed some very weird things happening with my current MySQL setup on my XP Laptop, a development machine. For a while, I have been trying to get the MySQL cache to work....
8
by: Fred | last post by:
Hello, Our website is currently developed in ASP/Mysql 4. The dedicated servers on which it is currently hosted arrive at saturation. Here is their configuration: - 1 server PIV 2,8Ghz 1GB...
6
by: Ridge Burner | last post by:
Can someone tell me which of these 2 SQL queries will be more efficient? I'm having a debate with another guy about which would be less resource intensive for MySQL. The first uses MySQL to pick...
0
by: Mike Husler | last post by:
I have been tasked with copying data from our SQL Server to a local MySQL (windows). About 75 tables are involved. The data arrive in SQL Server at irregular cadences. Some every 1/2 second,...
11
by: stantron | last post by:
Setup: I only have one database with one table in it. The first page has a form that adds a record (w/ 6 fields in it) to the mySQL database's lone table via PHP. This works fine. I also have a PHP...
3
by: thesmithman | last post by:
Well, actually, I'm sure it's my code... I have a basic nested query: $query="INSERT INTO items (blah, blah, blah) VALUES ('$blah', '$blahblah', NULL)"; $result=mysql_query($query) or...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.