select query issue

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

select query issue

Post by itsmani1 »

Hi

I have two tables

questions
answers

One question can have many answers

i want to select all the questions with all answers

i also want to select the questions which are not answered yet.

thank you
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: select query issue

Post by John Cartwright »

Code: Select all

SELECT * FROM `questions`
LEFT JOIN `answers` ON `quesions`.`id` = `answers`.`question_id`
:)
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: select query issue

Post by aceconcepts »

This link offers a rather straightforward approach to JOIN queries: http://w3schools.com/sql/sql_join.asp
Post Reply