SQL
SQL Parentheses use in an OR clause
Take a look at the Operator Precedence in SQL Server (You’ve not specified that, but I’d imagine it’s the same for all RDBMS). What this means is that ANDs (without parenthesis) are evaluated before1 bind more tightly than ORs. So in your specific case, without the parenthesis, the conditions are: employe.service=service.code_serv AND employe.nom LIKE ‘A%’ OR employe.nom LIKE ‘B%’ … Read more
Query to convert from datetime to date mysql
Try to cast it as a DATE
MySQL starts with searching issue
Underscore is a wildcard for a single character. You will need to change your SQL to something like: Or you can escape the underscore
How do I reset a sequence in Oracle?
Here is a good procedure for resetting any sequence to 0 from Oracle guru Tom Kyte. Great discussion on the pros and cons in the links below too. From this page: Dynamic SQL to reset sequence valueAnother good discussion is also here: How to reset sequences?
How to divide two columns?
Presumably, those columns are integer columns – which will be the reason as the result of the calculation will be of the same type. e.g. if you do this: you will get 0, which is obviously not the real answer. So, convert the values to e.g. decimal and do the calculation based on that datatype … Read more
Convert timestamp to date in Oracle SQL
For example, The query is : SELECT CAST(SYSTIMESTAMP AS DATE) FROM dual;
Comparing Dates in Oracle SQL
31-DEC-95 isn’t a string, nor is 20-JUN-94. They’re numbers with some extra stuff added on the end. This should be ’31-DEC-95′ or ’20-JUN-94′ – note the single quote, ‘. This will enable you to do a string comparison. However, you’re not doing a string comparison; you’re doing a date comparison. You should transform your string into a date. Either by using the built-in TO_DATE() function, … Read more
Insert into a MySQL table or update if exists
Use INSERT … ON DUPLICATE KEY UPDATE QUERY: