Solved

Selecting data from two tables at the same time

Posted on 2016-10-21
4
10 Views
Last Modified: 2016-10-21
Can i select data from two tables with a single sql sentence and use fetch_assoc and while loop to print the mixed data coming from two tables?
0
Comment
Question by:Braveheartli
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Evan Cutler
ID: 41854486
can you please put in code you have already worked on?  This may become easier to answer if we know what we are dealing with.  Thanks.
0
 
LVL 1

Author Comment

by:Braveheartli
ID: 41854495
I'm out of office right now, however what i want to learn is : can i select data like this and print it out with fetch function and while loop?

SELECT * FROM member
LEFT JOIN networking
ON member.networkingID=networking.ID
WHERE member.ID=2
0
 
LVL 9

Accepted Solution

by:
Evan Cutler earned 500 total points
ID: 41854497
yes.  but using the asterik(*) provides an issue of names identical in both tables.
in order to fetch across the resulting dataset, you will be sucked into a fully qualified column name (ie. networking.column1 and member.column1).  you might want to qualify those names first (ie. netcol1 and memcol1) and use individual columns names instead of the asterik(*).
0
 
LVL 1

Author Closing Comment

by:Braveheartli
ID: 41854501
Thank you
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now