1,720 reputation
621
bio website
location Ukraine
age
visits member for 2 years, 8 months
seen 4 hours ago

Nov
7
comment Make “as” mandatory when create column alias?
My reasoning is this. If you forget about the rule altogether, your query ends up with columns unprefixed and you thus risk running into the original issue, so here the hardest part is probably getting used to the rule. When you do remember about it, then a missing table alias might be easier to spot at a glance than a missing comma because the former would probably stand out among the rest to a greater degree than the latter. It is still possible to happen, of course, but then I would expect the chance of missing both the alias and the preceding comma to be less than that of missing either.
Nov
6
answered Make “as” mandatory when create column alias?
Nov
4
comment Understanding Indexes and using them better
When you said you tried optimising your queries, did you mean you tried only fiddling with DB/server settings, table indices etc. or did you also try rewriting the queries themselves? You aren't offering us to take a look at them, I guess you must reckon you've optimised them as much as could be, or do you think there could still be room for more optimisation?
Nov
4
comment MySQL temporary column in SELECT statement
You seem to completely misunderstand the purpose of HAVING, and the indulgent nature of MySQL extensions to SQL doesn't help at all. Do you realise that using HAVING in this way you can only get one row out of the query? Did you mean the result to consist of just one row? I'm asking this because my answer, if I ever get round to writing one, would depend on that.
Nov
3
comment MySQL temporary column in SELECT statement
What is this query supposed to do? In particular, what do you mean by using HAVING without GROUP BY?
Oct
24
awarded  Quorum
Oct
14
comment SQL Server Decimal(9, 0) vs INT
Thank you for the offer. @Chris Chubb has already referred to that point in his answer, so I'm not posting mine until I find something to balance/complement it with. If that's the single aspect that you care most about, though, feel free to post your own answer. There may be additional value to your answer if you explain why that aspect is so important in your particular case.
Oct
14
comment Selecting the highest value in a column?
@billinkc: Their first take on the OVER clause was with the 2005 release. They didn't enhance it until the 2012 version.
Sep
10
revised Constant values in columns
grammar
Sep
9
comment Database Design for lookup tables
So, again, fix the design (by allocating separate tables for different entities), and perhaps it will then be much easier for you to answer your original question yourself.
Sep
9
comment Database Design for lookup tables
Oh I see. Perhaps, "terrible" was a bit too harsh on my side and if the supporting team is happy with the present idea, good for you. It's just that I would hate to be on that team. :) My issue with this design is mainly about the referential integrity. Although the server would prohibit you from inserting a non-existent reference into any of the reference columns, it would allow you to insert one pointing to an entirely different thing than the column is supposed to hold, just as I said above and as the already mentioned example shows.
Sep
9
comment Database Design for lookup tables
@Polppan: Yes, separate tables for different things. The example by Ypercube shows that with your design you would be allowed to insert references into wrong columns. For instance, you would be able to insert a type into the category column and the other way round. How did you come up with this design in the first place? Is this an exercise, a working project, or something else?
Sep
9
comment Database Design for lookup tables
From your SQL Fiddle, it appears the answer to my question is "yes". That's a terrible design. You should have distinct tables for distinct entities. There should be a Category table, or perhaps even two: question_category, product_category, same for types and other things. You shouldn't mix all those in one table.
Sep
9
comment Database Design for lookup tables
Do you mean you have multiple foreign key columns and one and the same table & column that those FKs are referencing?
Aug
28
revised Constant values in columns
added 10 characters in body
Aug
28
answered Constant values in columns
Aug
28
revised Dynamic file name for file import
added relevant tags
Aug
28
suggested suggested edit on Dynamic file name for file import
Aug
27
comment How to relate two rows in the same table
Even if for some reason INSERT VALUES had worked differently from INSERT SELECT, there would still have been the option of INSERT INTO t SELECT 1, 5 UNION ALL SELECT 5, 1, which you say you are aware is considered a single statement.
Aug
21
revised EF Code First uses nvarchar(max) for all strings. Will this hurt query performance?
capitalisation