Selecting data in php - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > PHP Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-20-2011, 11:15 PM   #1 (permalink)
Member
 
Join Date: Jul 2010
Posts: 289
Default Selecting data in php

hi friendz
I want to get data from two tables

Example
table 1 with fields id,author,profession,country

table 2 with fields id,quote,author,category

So in this way i want to select quote from table 2 whose author and profeesion is specific

$result = mysql_query("SELECT quote FROM table 2 where author="harry" and profession = "Scientist");


Is there any way that i can select like this
lapunluyang is offline   Reply With Quote
Sponsored Links
Old 03-22-2011, 01:09 AM   #2 (permalink)
Junior Member
 
Join Date: Feb 2011
Posts: 25
Default Re: Selecting data in php

This one is the Perfect query........
anderson111 is offline   Reply With Quote
Old 03-22-2011, 05:10 AM   #3 (permalink)
Junior Member
 
Join Date: Jun 2010
Location: Houston
Posts: 26
Default Re: Selecting data in php

How are the two tables linked to each other? Do you have a foreign key or something in the quotes table?
ap2010 is offline   Reply With Quote
Old 04-08-2011, 12:11 PM   #4 (permalink)
Regular User
 
Join Date: Apr 2011
Posts: 115
Default Re: Selecting data in php

It seems that Id is the PK and FK,
Y dont u use Joins?
chunnilal is offline   Reply With Quote
Old 04-08-2011, 06:11 PM   #5 (permalink)
Junior Member
 
Join Date: Apr 2011
Location: Los Angeles, California
Posts: 44
Default Re: Selecting data in php

Code:
SELECT t2.quote, t2.author, t1.profession
FROM table2 t2
  LEFT JOIN table1 t1 ON t2.author = t1.author
OR, if author's table1's id = author's table2's id you could do:

Code:
select t2.quote, t2.author, t1.profession
   from table1 t1, table2 t2
   where t1.id = t2.id
websonalized is offline   Reply With Quote
Old 04-14-2011, 02:54 AM   #6 (permalink)
Member
 
Join Date: Apr 2011
Posts: 136
Default Re: Selecting data in php

hello websonalized

thanks for sharing this code
sweetsianjali is offline   Reply With Quote
Old 04-15-2011, 07:35 AM   #7 (permalink)
Member
 
Join Date: Apr 2011
Posts: 136
Red face Re: Selecting data in php

I have just try this code it's working,Thank you.

Euflexxa
Buy Actonel Online
Buy Orthovisc
sweetsianjali is offline   Reply With Quote
Old 06-17-2011, 01:12 AM   #8 (permalink)
Junior Member
 
danieljames123's Avatar
 
Join Date: May 2011
Posts: 72
Default Re: Selecting data in php

I also thanking you because it is also help to me. And I think you are great helper here.

_____________________
Php Development India
danieljames123 is offline   Reply With Quote
Old 06-24-2011, 02:43 AM   #9 (permalink)
Regular User
 
jacqueline_davic's Avatar
 
Join Date: Jun 2011
Location: USA
Posts: 16
Default Re: Selecting data in php

thank you for that
jacqueline_davic is offline   Reply With Quote
Old 06-28-2011, 02:10 AM   #10 (permalink)
Junior Member
 
Join Date: Jun 2011
Posts: 57
Default Re: Selecting data in php

SELECT dbnames.tablenames.columnnames,db2names.table2name s.column2names FROM
dbnames.tablenames, db2names.table2names;
Thank you.

MBA | MBA Colleges in Mumbai
rahaul is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

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



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 04:38 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting