Use Condition (IF OR Case ) in SQL Statment
-
2 พฤษภาคม 2555 12:43
I want use condition if Column Null And Other Condition Like ID=X
Select From Another Column
Ahmed Osman
ตอบทั้งหมด
-
2 พฤษภาคม 2555 12:56
Use the CASE expression:SELECT CASE WHEN Column IS NULL AND ID = X THEN Column1 ELSE Column2 END FROM yourTable;
- แก้ไขโดย Stefan HoffmannMVP 2 พฤษภาคม 2555 12:57
- เสนอเป็นคำตอบโดย Elmozamil Elamir 3 พฤษภาคม 2555 6:49
- ทำเครื่องหมายเป็นคำตอบโดย Ahmed Osman2 3 พฤษภาคม 2555 10:43
-
2 พฤษภาคม 2555 13:09ผู้ดูแล
Hello,
You have forgotten to tell us for which DBMS (SQL Server , ORACLE, ACCESS). The version and edition could be also usefull
For SQL Server :
- test if a column is null ==> ISNULL http://msdn.microsoft.com/en-us/library/ms184325(SQL.100).aspx ( for SQL Server 2008 valid from 2005 )
have a look at http://msdn.microsoft.com/en-us/library/ms191270(SQL.100).aspx ( a comparaisn to null is not evident to understand )
- for AND operator : http://msdn.microsoft.com/en-us/library/ms189119(SQL.100).aspx
Please, could you provide the definition of your table and explain "Other Condition Like" ?
LIKE is existing in TRANSACT-SQL ( pattern matching in search ) http://msdn.microsoft.com/en-us/library/ms187489(SQL.100).aspx
Don't hesitate to post again for more help or explaination
Have a nice day
PS : if your thread is related to SQL Server , it is possible that a moderator moves your thread towards the Transact-SQL forum where it will interest more people ( this forum is mainly for connection or protocols problems )
Mark Post as helpful if it provides any help.Otherwise,leave it as it is.
-
3 พฤษภาคม 2555 10:43
Thanks Stefan Hoffmann
thats Help me
Ahmed Osman