I have a table named user with a field of type SET named privs. The allowed values of this field are: ‘ADD’,’EDIT’,DELETE’,’ALL’. What SQL query should I execute to add let’s say value ‘EDIT’ to the field privs for a given row? But only if there is n…
Converting Numbers to Words in MYSQL result! Using Query
I am trying to print a output as follows when I execute a query in mysql. Name Salary Sal_in_Words Mohan 45000 Rupees Forty Five Thousand Only The column Salary has a value 45000 and in the …
Select EMP with max SAL from each DEPT
I´m having a bad time with a SQL query. I´m using oracle default tables: ‘EMP’ TABLE http://imageshack.us/photo/my-images/850/sinttuloxps.png/ AND ‘DEPT’ TABLE http://imageshack.us/photo/my-images/19/assayp.png/ I wan´t to get the employee with the highest salary in each department. I´…
Oracle equivalent of INSERT IGNORE
I found a very similar topic on Oracle Equivalent to MySQL INSERT IGNORE? However, I could not make work any of the proposed solutions. My case is a little special as my table does contains only 1 field, which is the primary key. Let’s call the field “id” and the table “myTable” …
How to use named parameter in plain sql with jooq
I’m using JOOQ with plain/raw SQL, so that means i’m not using any code generation or the fluid DSL thingy. The following code works: Now let’s say i have a query with multiple parameters like this: How do i use a named parameter with these types of queries? I’m thinking something like…
Combining the results of two SQL queries as separate columns
I have two queries which return separate result sets, and the queries are returning the correct output. How can I combine these two queries into one so that I can get one single result set with each result in a separate column? Query 1: Query 2: Thanks. Answer You can aliasing both query and Selecting them in…
SQL “between” not inclusive
I have a query like this: But this gives no results even though there is data on the 1st. created_at looks like 2013-05-01 22:25:19, I suspect it has to do with the time? How could this be resolved? It works just fine if I do larger date ranges, but it should (inclusive) work with a single date too. Answer It
How to select distinct year from a datetime column and add the result to a comboBox in C#?
I am using visual studio 2010 and SQL Management Studio R2 Although the sql query works fine in sql management studio. Its throws an exception in visual studio. Out of index exception whem i edit to make any other adjustments it throws Out of format exception. Please Help me. The code is as follows: Answer Yo…
REGEXP_LIKE conversion in SQL Server T-SQL
I have come across this line in an old report that needs converting to SQL Server. examCodes being the source and learner_code being the pattern. I know that SQL Server doesn’t have REGEXP_LIKE and most places tell you to use PATINDEX. Here’s me thinking that this would work: But I get the error: …
sqlalchemy,creating an sqlite database if it doesn’t exist
I am trying out sqlalchemy and i am using this connection string to connect to my databases Does sqlalchemy create an sqlite database for you if one is not already present in a directory it was supposed to fetch the database file?. Answer Yes,sqlalchemy does create a database for you.I confirmed it on windows…