I have a SQL query with where clause, I have created the index for the columns which are being used in the where clause. How can I check the query is using the indexes for these columns? Answer Write “explain ” in front of your query. The result will tell you which indexes might be used. For example: You can
Tag: mysql
USE % WILD IN WHERE CLAUSE
I have a record in my MySQL database which is a varchar type for e.g I am running a query to fetch this record, say the column name is NAME and table name is DATA. so my query is ……… But this query isn’t fetching any record Tell me any possible way to fetch this particular record through this ‘%john;jack;steve%’
I have error “#1363 – There is no NEW row in on DELETE trigger “
I have table “book” and “store_order” have relation I want to make trigger(but it contain error): Answer
Querying MySQL database using Python
I have a table named ‘staff’, with several columns, but the two I’m interested in are ‘username’ and ‘password’. I am trying to create a prompt which asks the user for their username (and later I will do password) and checks the table in the database to see if that username exists. I am a bit clueless about how to
How do I make aggregate query return empty set instead of NULL row?
I have a SQL query like this: However, when t2 selection is empty, it returns a row containing NULL values (because of MAX function returning NULL when called on an empty set). I would like it to return an empty set instead. How can I achieve it? Answer Try this in sql server … try this in Mysql
Why would MySQL execute return None?
I am trying to query on a local MySQL database using Python’s (3.4) MySQL module with the following code: As far as I can tell, the connection is successful, the database is composed of several rows but the query always returns the none type. What instances does the MySQL execute function return None? Answer Query executions have no return values.
How to cross join a table and use fields from the select statment in the where clause of the cross join
Unfortunately I cannot make this a procedure in this case. I’m setting the variables in the select statement and using them in my cross join. My Count(*) as Line Item is 0… What am I doing wrong? Answer
MySQL error 1093. how to delete from this
Select worked: delete doesn’t work: Error Code: 1093. You can’t specify target table ‘pre_log’ for update in FROM clause 0,001 sec Answer You have specified pre_log table in your sub query from which you actually Delete the records try this might help you..
java.sql.SQLException: Field ‘id’ doesn’t have a default value
I am trying to insert data into arrivaltimes tables but I am getting the following error: java.sql.SQLException: Field ‘id’ doesn’t have a default value Answer You are missing AUTO INCREMENT for Primary Key in arrivaltimes table. Just need to add AUTO_INCREMENT while creating table
How to select only the first elements satisfying a condition?
I have the following table (simplification of the real problem): Now a simple SELECT id FROM Table WHERE value=’T’; would get me all the IDs where value is T, but I just need, in the example above, the first 2 (1 and 2). What is the best way to do this? I’d prefer not to use a while loop. I