SQL server ignore case in a where expression

In the default configuration of a SQL Server database, string comparisons are case-insensitive. If your database overrides this setting (through the use of an alternate collation), then you’ll need to specify what sort of collation to use in your query. SELECT * FROM myTable WHERE myField = ‘sOmeVal’ COLLATE SQL_Latin1_General_CP1_CI_AS Note that the collation I … Read more

MySQL – ORDER BY values within IN()

SELECT id, name FROM mytable WHERE name IN (‘B’, ‘A’, ‘D’, ‘E’, ‘C’) ORDER BY FIELD(name, ‘B’, ‘A’, ‘D’, ‘E’, ‘C’) The FIELD function returns the position of the first string in the remaining list of strings. However, it is much better performance-wise to have an indexed column that represents your sort order, and then … Read more

MySQL join with where clause

You need to put it in the join clause, not the where: SELECT * FROM categories LEFT JOIN user_category_subscriptions ON user_category_subscriptions.category_id = categories.category_id and user_category_subscriptions.user_id =1 See, with an inner join, putting a clause in the join or the where is equivalent. However, with an outer join, they are vastly different. As a join condition, … Read more

techhipbettruvabetnorabahisbahis forumu