CREATE TABLE dbo.MainTable
(
ID bigint IDENTITY NOT NULL,
DateCreate Date NOT NULL,
UserName nvarchar(50) NOT NULL
);
CREATE TABLE dbo.SubTable
(
ID bigint IDENTITY NOT NULL,
MainID bigint NOT NULL,
ShortDescription nvarchar(100) NOT NULL
);
SELECT MT.ID, MT.DateCreate, MT.UserName, ST.ShortDescription
FROM dbo.MainTable MT INNER JOIN
dbo.SubTable ON MT.ID = ST.MainID
WHERE MT.UserName = 'AwesomeUser'
ORDER BY MT.DateCreate DESC;
CREATE TABLE dbo.MainTable
(
ID bigint IDENTITY NOT NULL,
DateCreate Date NOT NULL,
UserName nvarchar(50) NOT NULL
);
CREATE TABLE dbo.SubTable
(
ID bigint IDENTITY NOT NULL,
MainID bigint NOT NULL,
ShortDescription nvarchar(100) NOT NULL
);
SELECT MT.ID, MT.DateCreate, MT.UserName, ST.ShortDescription
FROM dbo.MainTable MT INNER JOIN
dbo.SubTable ON MT.ID = ST.MainID
WHERE MT.UserName = 'AwesomeUser'
ORDER BY MT.DateCreate DESC;
Looks pretty good. I think we could do better, lets use some syntax highlighter,
CREATE TABLE dbo.MainTable ( ID bigint IDENTITY NOT NULL, DateCreate Date NOT NULL, UserName nvarchar(50) NOT NULL ); CREATE TABLE dbo.SubTable ( ID bigint IDENTITY NOT NULL, MainID bigint NOT NULL, ShortDescription nvarchar(100) NOT NULL ); SELECT MT.ID, MT.DateCreate, MT.UserName, ST.ShortDescription FROM dbo.MainTable MT INNER JOIN dbo.SubTable ON MT.ID = ST.MainID WHERE MT.UserName = 'AwesomeUser' ORDER BY MT.DateCreate DESC;
I don't know about you, but this look awesome to me (it may not show the syntax highlighting in your RSS reader) . It shows a similar appearance like what the regular coder familiar with. To me, it is much more readable. If you like what syntax highlighter that is being used here, follow this link for the instructions.
No comments:
Post a Comment