Click here to Skip to main content
15,922,407 members
Home / Discussions / Database
   

Database

 
GeneralRe: remove commas in a column in mssql Pin
phokojoe28-Aug-08 4:20
phokojoe28-Aug-08 4:20 
GeneralRe: remove commas in a column in mssql Pin
Blue_Boy28-Aug-08 4:27
Blue_Boy28-Aug-08 4:27 
GeneralRe: remove commas in a column in mssql Pin
phokojoe28-Aug-08 4:51
phokojoe28-Aug-08 4:51 
GeneralRe: remove commas in a column in mssql Pin
Blue_Boy28-Aug-08 5:06
Blue_Boy28-Aug-08 5:06 
QuestionHow to use a string variable in SQL query string? Pin
chenayang27-Aug-08 18:43
chenayang27-Aug-08 18:43 
AnswerRe: How to use a string variable in SQL query string? Pin
N a v a n e e t h27-Aug-08 19:33
N a v a n e e t h27-Aug-08 19:33 
GeneralRe: How to use a string variable in SQL query string? Pin
chenayang27-Aug-08 23:42
chenayang27-Aug-08 23:42 
QuestionProblem with SQL Query doing inner joins [modified] Pin
Sunset Towers27-Aug-08 14:23
Sunset Towers27-Aug-08 14:23 
I'm running the following query and it is giving me a major problem.

SELECT Listings.ListingID, Listings.Title, Listings.HasPhoto, Listings.IsTaken, Listings.IsPickedUp, Listings.TakenDate, Listings.PickedUp, Listings.TimesViewed, Categories.CategoryName, Members.dbo.Members.LoginID, Listings.Submitted, Listings.Approved, GetTakenMemberName.LoginID AS TakenMemberName
FROM Listings INNER JOIN
Categories ON Listings.CategoryID = Categories.CategoryID INNER JOIN
Members.dbo.Members ON Listings.MemberID = Members.dbo.Members.MemberID INNER JOIN
Members.dbo.Members AS GetTakenMemberName ON Listings.TakenBy = GetTakenMemberName.MemberID
WHERE (Listings.MemberID = @MemberID)

If I remove

INNER JOIN Members.dbo.Members AS GetTakenMemberName ON Listings.TakenBy = GetTakenMemberName.MemberID

which is the last join and

GetTakenMemberName.LoginID AS TakenMemberName

from the SELECT portion, the query runs without a problem and gives a result. With those statements in however the result is an empty table. Currently there is only one record in the Listings and Members table, so as far as I'm concerned TakenMemberName should be returning as null or empty.

I even tried using an all 0 guid in the TakenBy field so at least the query would have something to look for during the SELECT. However, that didn't work either.

[Modified]
On further investigation I have found that if I put an actual member in the TakenBy field that the query executes with out problem, but if the query doesn't match a member then the entire select fails. How can I prevent that from happening?

modified on Wednesday, August 27, 2008 10:08 PM

AnswerRe: Problem with SQL Query doing inner joins Pin
PIEBALDconsult27-Aug-08 16:09
mvePIEBALDconsult27-Aug-08 16:09 
GeneralRe: Problem with SQL Query doing inner joins Pin
Sunset Towers27-Aug-08 16:14
Sunset Towers27-Aug-08 16:14 
QuestionInput requested on SQL Random String Generator Pin
Jesse Wimberley27-Aug-08 13:47
Jesse Wimberley27-Aug-08 13:47 
Questionbetween max() and min() Pin
nelsonpaixao27-Aug-08 13:33
nelsonpaixao27-Aug-08 13:33 
AnswerRe: between max() and min() Pin
TheFM23427-Aug-08 13:52
TheFM23427-Aug-08 13:52 
AnswerRe: between max() and min() Pin
Blue_Boy27-Aug-08 21:02
Blue_Boy27-Aug-08 21:02 
AnswerRe: between max() and min() Pin
MatthysDT28-Aug-08 1:34
MatthysDT28-Aug-08 1:34 
Questionarray Pin
nelsonpaixao27-Aug-08 13:09
nelsonpaixao27-Aug-08 13:09 
AnswerRe: array Pin
Ashfield27-Aug-08 20:57
Ashfield27-Aug-08 20:57 
AnswerRe: array Pin
MatthysDT28-Aug-08 1:56
MatthysDT28-Aug-08 1:56 
Questiontable Pin
nelsonpaixao27-Aug-08 13:02
nelsonpaixao27-Aug-08 13:02 
AnswerRe: table Pin
Ashfield27-Aug-08 20:50
Ashfield27-Aug-08 20:50 
AnswerRe: table Pin
TheFM23428-Aug-08 16:54
TheFM23428-Aug-08 16:54 
QuestionGrouping by most recent date Pin
Netblue27-Aug-08 8:21
Netblue27-Aug-08 8:21 
AnswerRe: Grouping by most recent date Pin
Ashfield27-Aug-08 8:57
Ashfield27-Aug-08 8:57 
GeneralRe: Grouping by most recent date Pin
Netblue27-Aug-08 9:07
Netblue27-Aug-08 9:07 
GeneralRe: Grouping by most recent date Pin
Ashfield27-Aug-08 21:53
Ashfield27-Aug-08 21:53 

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.