Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select ISNull Problem

Status
Not open for further replies.

autumnEND

Programmer
Nov 1, 2005
61
GB
Ive created the following code , to select items from my sql database.

the field m.avatar is an image data type and is eithor NULL or contains data such as <system byte> etc

im wanting to select the data from the database even if m.avatar is null or has data. And it wont seem to let me.

The error it gives is, incorrect syntax near '.'. error.

SELECT ISNULL(m.avatar, 0 ) AS m.avatar, m.memberid, f.topicID, f.postID, f.postTITLE, f.postBY, f.postDATE
FROM forum_posts AS f LEFT JOIN
memberinfo AS m ON f.postBY = m.username
GROUP BY m.memberid, m.avatar, f.topicID, f.postID, f.postTITLE, f.postBY, f.postDATE
ORDER BY postID DESC

ANy help would be appreciated, thank you .
 
I tried .

SELECT ISNULL(m.avatar, 0 ) AS avatar, m.memberid, f.topicID, f.postID, f.postTITLE, f.postBY, f.postDATE
FROM forum_posts AS f LEFT JOIN
memberinfo AS m ON f.postBY = m.username
GROUP BY m.memberid, m.avatar, f.topicID, f.postID, f.postTITLE, f.postBY, f.postDATE
ORDER BY postID DESC

And it gave the following error .

There was an error executing the query.
Please check the syntax of the command and if present,the types and values of the paramaters and ensure they are correct.

The text, ntext and image data types cannot be compaired or sorted, except when using IS NULL or LIKE operator .

he problem must lie within the GROUP BY

Im lost .
 
why do you even have a GROUP BY clause? you aren't counting or summing or anything like that

the only other reason for GROUP BY is to remove duplicates, but it would be incredibly unusual for you to have duplicate posts with the exact same avatar, memberid, topicID, postID, postTITLE, postBY, and postDATE


r937.com | rudy.ca
 
Yep i see what you mean, i removed GROUP BY and made a few more changes and now it works fine .

Thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top