Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Query Help

Author  Topic 

alexz22
Starting Member

7 Posts

Posted - 2011-02-15 : 12:12:37
I got a message board table
with the follwoing fields title, message, studentID and Private.
If Private is True, then I want only the student that posted the message to view be able to view it.

I need help here
Select * From Mboard where ....


RobertKaucher
Posting Yak Master

169 Posts

Posted - 2011-02-15 : 12:57:07
Is this MS SQL Server? Not MySQL?

SELECT Column1
,Column2
--ETC...
WHERE Private = 'true'

Without more information about your tables that's the best I can do for you....

===
http://www.ElementalSQL.com/
Go to Top of Page

alexz22
Starting Member

7 Posts

Posted - 2011-02-15 : 13:07:57
Its actualy an access DB but will be later on SQL express addition.
Your query will only show thise marked privaste. What I want is...
If I posted a messagee and marked is privae, I will see it but not messages someone else posted and marked private
Go to Top of Page

RobertKaucher
Posting Yak Master

169 Posts

Posted - 2011-02-15 : 13:09:35
Could you post your table structure? Then I could offer a better suggestion to you.

What ever is running the query would need to be aware of the studentID and pass it as a variable so that you could compare

WHERE isPrivate = 'true' AND studentID = @studentID

===
http://www.ElementalSQL.com/
Go to Top of Page

alexz22
Starting Member

7 Posts

Posted - 2011-02-15 : 13:19:53
This simplified a little.
I'm trying to show all messages where thee courseID=CID and Private if flase. But I do need view private messages that i posted.
SQL = "SELECT MBoard.courseID, MBoard.studentID, MBoard.name, MBoard.tirle, MBoard.message, MBoard.private From MBoard WHERE (((MBoard.courseID)="& CID &") AND ((MBoard.Private)<>True)) "
Go to Top of Page
   

- Advertisement -