i have retrieved mysql data from one table in json using the following script - $table_first = 'abc';
-
$query = "SELECT * FROM $table_first";
-
$resouter = mysql_query($query, $conn);
-
-
$set = array();
-
-
$total_records = mysql_numrows($resouter);
-
if($total_records >= 1){
-
-
while ($link = mysql_fetch_array($resouter, MYSQL_ASSOC)){
-
$set[] = $link;
-
}
-
}
-
-
echo json_encode($set);
how can i retrieved data from two other tables in which there is a foreign key of this table in both of those tables. OR simply how can i retrieved data from 3 mysql tables in php.
5 2392 code green 1,726
Recognized Expert Top Contributor
I don't know what json does but the query will need two joins.
Maybe it is a question better asked on the MySQL forum.
I doubt you will want SELECT * when joining three tables
the join query returns all the data at once what i want to do is that to retrieved the relevant records. i.e for id 1 of first table there are 5 relevant records in second table and 3 records relevant to this in third table.
i want to print the id 1 of table one than all the relevant records of table 2 and table 3.
And same for id 2 of table 1......
code green 1,726
Recognized Expert Top Contributor
the join query returns all the data at once what i want to do is that to retrieved the relevant records
Which is why I suggested not to use SELECT *.
Your SELECT string should detail which fields you require.
I can't help anymore without the table structures and the required output in tabular form
my table structure is
recipe{rec_id,n ame,overview,ca tegory,time,ima ge}
ingredients{ing redient_id,ingr edient_name,amm ount,rec_id}
instructions{in struction_id,in struction_text, rec_id}
look at rec_id which is foreign key in both tables.
so queries should be - $query1="select * from recipe";
-
than it should iterate in table2 against the relevant id from table1;
e.g - $query2="select specific_field from ingredients where rec_id='rec_id from table1';
code green 1,726
Recognized Expert Top Contributor
I suggest putting the query question on MySQL forum.
But MySQL won't do what you are expecting it to do.
You will need an explicit JOIN, primary-foreign keys are ignored.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: AMD |
last post by:
Hi,
I would like to have MySQL use a mapped network drive. I'd like to do
this in case there is a failure of the mysql machine, I can just replace
it with a new machine pointing to the same network drive. Is this
possible at all?
Thanks,
Andre M. Descombes
|
by: jonas |
last post by:
Guys was wondering has any done this
I need to get a heads up as i need to grab data from a databasemake some changes and then put it back in place
I'm guessing the MySqlDB Module be it seems to be server side based...
where might i start any examples out there i've tried the google thang but not much
later
J
|
by: im2kul2 |
last post by:
I'd be GREATLY APRECIATED if someone could bail me out of this one! I
logged into my server an hour ago just to find that the root partition
is 100% filled:
/dev/mapper/VolGroup00-LogVol00
34285296 32544556 0 100% /
Because of that (I think), the data directory associated with my MySQL
installation got shot (read: disappeared!).
|
by: Bill |
last post by:
Hi,
I try to connect to Mysql using the Mysql Connector 1.0.7. with asp.net 2.O.
In "mysql.aspx", i put:
<%@ import namespace="System.Data"%>
<%@ Import Namespace = "MySql.Data.MySqlClient" %>
.....
In "mysql.aspx.vb", i put:
|
by: Elric02 |
last post by:
I'm currently trying to get access to the Python source code, however
whenever I try to extract the files using the latest version of WinZip
(version 10) I get the following error "error reading header after
processing 0 entries"
I was under the impression that I could (from reading the various posts
on this group) that I could simply extract the tar ball, using WinZip.
If this is not the case does anybody know how I can actually get...
| |
by: Brian Huether |
last post by:
My webhost does not give me shell access. Normally, I use this sort of
command on my local machine:
c:\datac:\mysql\bin\mysql -uroot -pxxxxx db < file.sql
My webhost gives me PhpMyAdmin access, but I can never use that successfully
with large files. The sql file I need to import is 15MB.
thanks,
|
by: maverickx |
last post by:
Hi everyone,
this is about my one project, i was planning to do like this: Firstly i printed out the source code of one html page on the DOS window, and then use PERL Regular Expression to extract specifc data from the source code , at last save these data in MYSQL tables. Does this work?
|
by: Carmine [www.thetotalsite.it] |
last post by:
Hi,
I am using ASP.Net 2.0 with the MySQL Connector .Net 5.1.2.2.
I added these lines to the web.config to make the connector.net able to
handle the SqlConnection object (and so to bind it to a grinview/formview
etc.):
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,
|
by: crocodilu2008 |
last post by:
Why this not working ?
Our SQL table.
username email
tommy tommy@example.com
jane jane@example.com
jack jack@example.com
|
by: Zack00000 |
last post by:
Hi Guys,
I have a problem with the dll of MySql connector for .NET. To illustrate the problem, I have 3 projects:
First one is a wrapper for log4net (it's a logging api), it is using log4net.dll as dependency and build as MyLog.dll:
using log4net;
namespace MyLog
{
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |