@manhng

Welcome to my blog!

Sql Select

March 12, 2018 16:35

CREATE TABLE

CREATE TABLE [dbo].[tb_admin_logs](
[id] [int] NOT NULL PRIMARY KEY,
[user_id] [int] NULL,
[type] [int] NULL,
[description] [nvarchar](max) NULL,
[created_at] [datetime] NULL,
[updated_at] [datetime] NULL,
[deleted_at] [datetime] NULL
)

GO

QUERY 

SELECT userId = CASE
WHEN al.user_id IS NULL
THEN 0
ELSE al.user_id
END
,al.id
,al.type
,al.description
,al.created_at
,al.updated_at
,al.deleted_at
FROM tb_admin_logs al

GO

Categories

Recent posts