Click here to Skip to main content
15,881,757 members
Home / Discussions / Database
   

Database

 
AnswerRe: In SQL Server, how to generate table script as a single statement? Pin
Mycroft Holmes15-Jun-12 13:38
professionalMycroft Holmes15-Jun-12 13:38 
Questioni want to do left join that should not return same multiple rows Pin
asifkhan114-Jun-12 1:45
asifkhan114-Jun-12 1:45 
AnswerRe: i want to do left join that should not return same multiple rows Pin
DRKARTHIKRAJ14-Jun-12 2:32
DRKARTHIKRAJ14-Jun-12 2:32 
AnswerRe: i want to do left join that should not return same multiple rows Pin
asifkhan114-Jun-12 3:09
asifkhan114-Jun-12 3:09 
GeneralRe: i want to do left join that should not return same multiple rows Pin
DRKARTHIKRAJ15-Jun-12 1:53
DRKARTHIKRAJ15-Jun-12 1:53 
AnswerRe: i want to do left join that should not return same multiple rows Pin
Eddy Vluggen14-Jun-12 2:39
professionalEddy Vluggen14-Jun-12 2:39 
AnswerRe: i want to do left join that should not return same multiple rows Pin
Nolan Sunico14-Jun-12 5:03
Nolan Sunico14-Jun-12 5:03 
AnswerRe: i want to do left join that should not return same multiple rows Pin
Michael Potter15-Jun-12 10:43
Michael Potter15-Jun-12 10:43 
Not sure why you have the second join to the history table. If each upload has a unique user and a unique history row, then user_id in the history table is useless information for this query. The second history join is giving you the redundant rows.

Try and avoid using DISTINCT and its variations. It requires the server to do more work and therefore slow down your query.


SQL
SELECT 
    US.name, 
    US.address, 
    UP.file_path, 
    UP.picture_path, 
    HS.location
FROM 
    [user] US
LEFT JOIN 
   uploads UP 
   ON (US.user_id = UP.user_id)
LEFT JOIN 
   history HS 
   ON (US.upload_id =  HS.upload_id)
WHERE 
   US.user_id = 5
ORDER BY 
   US.user_id


modified 15-Jun-12 16:51pm.

QuestionFinding "Missing" ID Numbers in Table (SQL Server 2005) Pin
Peter Bamuhigire13-Jun-12 7:25
Peter Bamuhigire13-Jun-12 7:25 
AnswerRe: Finding "Missing" ID Numbers in Table (SQL Server 2005) Pin
Mycroft Holmes13-Jun-12 14:45
professionalMycroft Holmes13-Jun-12 14:45 
AnswerRe: Finding "Missing" ID Numbers in Table (SQL Server 2005) Pin
Eddy Vluggen14-Jun-12 0:59
professionalEddy Vluggen14-Jun-12 0:59 
QuestionView might cause corruption? Pin
kmoorevs13-Jun-12 5:35
kmoorevs13-Jun-12 5:35 
AnswerRe: View might cause corruption? Pin
David Mujica13-Jun-12 5:56
David Mujica13-Jun-12 5:56 
AnswerRe: View might cause corruption? Pin
Pete O'Hanlon13-Jun-12 5:57
mvePete O'Hanlon13-Jun-12 5:57 
AnswerRe: View might cause corruption? Pin
Corporal Agarn13-Jun-12 5:57
professionalCorporal Agarn13-Jun-12 5:57 
AnswerRe: View might cause corruption? Pin
Mycroft Holmes13-Jun-12 14:52
professionalMycroft Holmes13-Jun-12 14:52 
GeneralRe: View might cause corruption? Pin
kmoorevs14-Jun-12 4:20
kmoorevs14-Jun-12 4:20 
QuestionMySQL Pin
klaydze12-Jun-12 21:54
klaydze12-Jun-12 21:54 
AnswerRe: MySQL Pin
Bernhard Hiller12-Jun-12 23:34
Bernhard Hiller12-Jun-12 23:34 
GeneralRe: MySQL Pin
klaydze13-Jun-12 1:33
klaydze13-Jun-12 1:33 
QuestionRemove a noise word in a SQL Server 2008 database Pin
Fernando A. Gomez F.12-Jun-12 13:55
Fernando A. Gomez F.12-Jun-12 13:55 
AnswerRe: Remove a noise word in a SQL Server 2008 database Pin
Bernhard Hiller13-Jun-12 0:00
Bernhard Hiller13-Jun-12 0:00 
GeneralRe: Remove a noise word in a SQL Server 2008 database Pin
Fernando A. Gomez F.13-Jun-12 5:05
Fernando A. Gomez F.13-Jun-12 5:05 
AnswerRe: Remove a noise word in a SQL Server 2008 database Pin
Eddy Vluggen13-Jun-12 1:24
professionalEddy Vluggen13-Jun-12 1:24 
GeneralRe: Remove a noise word in a SQL Server 2008 database Pin
Fernando A. Gomez F.13-Jun-12 5:06
Fernando A. Gomez F.13-Jun-12 5:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.