I have written a mysql query
select * from user where registration_date="2016-05-20"
But it returns wrong value. Please help me
Use
select * from user where date(registration_date)=date("2016-05-20")
Related
Can you please help me on the below query?
I have below select query, in which i want to pass a parameter dynamically to the hostname column. Is there way to achieve it?
select *
from All_HOSTS
where hostname='example.com'
order by FROM_UNIXTIME(start_epoch);
In ORACLE we have like this
select * from all_hosts where hostname=&1;
so it will ask parameter dynamically when I execute the select query - Is there way in MYSQL as well?
Please assist.
I am to not able to use the 'trunc(in oracle)' function in 'mysql' database. I have a table called dlb_cc_purchase and date field called due_date in my 'mysql' database. The data displaying in the date field like 20-11-2014 00:00:00 (20-nov-2014). in oracle we are using query
select * from dlbcc_purchase where trunc(due_date) = '20-nov-2014'
Oracle DB will fetch the row with due date 20-11-2014 00:00:00. How can I use this function in 'mysql'?
I know this is a basic question, but i was trying to do this for long time with truncate, str_to_date... but not able to fetch value. Please help.
Use DATE(expr) function. Query example:
SELECT *
FROM dlbcc_purchase
WHERE DATE(due_date) = '2014-11-20'
You can use DATE_FORMAT().
example:
select * from dlbcc_purchase where DATE_FORMAT(due_date,'%d-%b-%Y') = '20-nov-2014'
Previously I was using the MySQL. With that I was able to use the query below to get the maximum number from the database.
Here 'No' is the varchar(10):
SELECT max(cast(No as unsigned)) as No FROM `tableName` LIMIT 1
The above query working fine in MySQL. I want to do the same thing in the MS SQL. When I run the same query, I get the following error:
Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given
Any advice on this?
There is no LIMIT in SQL Server, no unsigned datatype, and no need to quote the table name.
Does this work:
SELECT max(cast(No as bigint)) as No FROM tableName
Problematic Query:
SELECT * FROM my_links WHERE taxonomy='ait-dir-item-category'
Above query returns no record and no error.
I am getting empty result, but I have exactly same value 'ait-dir-item-category' for taxonomy column.
But following query returns result
Perfect Query:
SELECT * FROM my_links WHERE taxonomy='post_tag'
Please tell me what is the problem.
Try with LIKE statment
SELECT * FROM my_links WHERE taxonomy LIKE '%ait-dir-item-category%'
Did you tried using like statement
Can you try like this,
select * from my_link where taxonomy like '%ait-dir-item%'
I have written a SELECT query, which will return a set of values, for ex.,
The following one is the actual table -
select data from tab1 where id <5; // This statement returns me the following table
I am trying to get the minimum value of the resultant table. I have tried the following query for that -
select MIN(select data from tab1 where id<5);
SQLite Browser says, there is an error in the select statement. My doubt is, whether we can give a select statement directly into an aggregate function like MIN()? If not, can you please suggest me a better way to do this task?
Thanks in advance.
Try this way:
select MIN(data)
from tab1 where id<5;