If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > select additional data

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-18-10, 08:25
albertkao albertkao is offline
Registered User
 
Join Date: Nov 2010
Posts: 2
select additional data

Given the following two SQL operations:
Code:
select prod_Id, P.proposal_id, P.institution_Name 
from proposals P 
group by P.proposal_ID 
having mark >= 50 
order by P.proposal_id desc 


select prod_id, P.proposal_id, PA.evaluator_ID, U.user_Given_Name, U.user_surname 
from users U, proposals P 
LEFT outer JOIN proposal_appraisal PA 
ON (P.proposal_Id = PA.proposal_id) 
where PA.evaluator_ID = U.user_id 
group by prod_id, PA.evaluator_ID 
order by PA.proposal_ID, U.user_ID desc
How to modify the following SQL operation so that prod_Id will be selected in addition to the existing columns being selected:
Code:
select PA.proposal_id, PA.evaluator_ID, PA.Primary_Evaluation_Status_ID, PA.Secondary_Evaluation_Status_ID, U.user_Given_Name, U.user_surname, 
from users U, proposal_appraisal PA 
where PA.evaluator_ID = U.user_id 
group by PA.proposal_id, PA.evaluator_ID 
order by PA.proposal_ID, U.user_ID desc
Reply With Quote
  #2 (permalink)  
Old 11-18-10, 08:59
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Code:
SELECT PA.proposal_id
     , PA.evaluator_ID
     , PA.Primary_Evaluation_Status_ID
     , PA.Secondary_Evaluation_Status_ID
     , U.user_Given_Name
     , U.user_surname
     , P.prod_id
  FROM users U
INNER
  JOIN proposal_appraisal PA 
    ON PA.evaluator_ID = U.user_id 
INNER
  JOIN proposals P 
    ON P.proposal_Id = PA.proposal_id
ORDER 
    BY PA.proposal_ID
     , U.user_ID desc
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On