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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL query help

Status
Not open for further replies.

supmktg

Technical User
Mar 30, 2003
5
US
I am moving a SQL Server db to mySQL. I'm new to mySQL.

I am trying to create a view in mySQL equivalent to this view from SQL Server:

"SELECT Project, Requirement, SubmitDate,
CASE WHEN [Rush] = 1 THEN '*' ELSE ' ' END AS 'InRush'
FROM ProjectTable"

Rush is a true false field. I am displaying data in a table and I need to display an asterisk if Rush = true, and blank if Rush = false.

Can someone help me with the correct SQL for this query?

Thanks,
Sup
 
Sorry for posting too quick. I figured it out:

"SELECT Project, Requirement, SubmitDate,
IF(Rush, "*", " ") AS InRush
FROM ProjectTable"
 
in case you should ever need to do something like this again, keep in mind that IF is proprietary syntax, whereas CASE is standard SQL

SELECT Project, Requirement, SubmitDate
, [blue]CASE WHEN Rush = 1 THEN '*' ELSE ' ' END AS InRush[/blue]
FROM ProjectTable

and yes, mysql supports CASE

:)

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top