-1

this is my database

the name of the table is sms_in

I would like to get sms_text using send_dt so i tried dis query

$query = mysql_query("SELECT  `sms_text` FROM `sms_in` WHERE 'sms_dt' = 2015-01-13");

but it doesn't show any result can anyone help me I'm new in query.

I'm trying to get the data for my website

sorry for the typo it's 'sent_dt' in my query not 'sms_dt'

Ram Aquino
  • 341
  • 3
  • 8

5 Answers5

0

first of all use mysqli instead mysql version. and if type of sms_dt is text then u should use single quotes''

$query = mysql_query("SELECT  sms_text FROM sms_in WHERE 'sms_dt' = '2015-01-13'");
habib ul haq
  • 824
  • 6
  • 13
  • is it ok if i use that even the date is datestamp?? how can i say this the date comes from sms messages date with the format YYYY-MM-DD, is it a text or object?? – Ram Aquino Jan 13 '15 at 06:01
  • Remove single quote on `sms_dt` and put backticks for that – Sadikhasan Jan 13 '15 at 06:04
0

Use quote of your column value don't column

$query = mysql_query("SELECT  `sms_text` FROM `sms_in` WHERE `sent_dt` = '2015-01-13'");

This question may help you

Community
  • 1
  • 1
Imran
  • 3,031
  • 4
  • 25
  • 41
0

Hello brother use single quotes for the date

$query = mysql_query("SELECT  `sms_text` FROM `sms_in` WHERE 'sms_dt' = '2015-01-13'");
Vamshi .goli
  • 522
  • 4
  • 13
0

Try this

Add single('') quote to date value not in date field:

$query = mysql_query("SELECT  `sms_text` FROM `sms_in` WHERE sms_dt = '2015-01-13'"); 

And also while seeing your table structure I found that there is no field with 'sms_dt' name , there is one date filed whose name is 'sent_dt' So please try with that field like:

$query = mysql_query("SELECT  `sms_text` FROM `sms_in` WHERE  sent_dt = '2015-01-13'"); 

I hope it will works work you !

Deepak Goswami
  • 2,030
  • 1
  • 16
  • 22
  • @Ram I am glad I could help you! thanks for accepting my answer. please vote it up also it will increase my ranking little more thanks again. – Deepak Goswami Jan 15 '15 at 12:33
-1

try to enclose your search criteria in single quotation: if your column is date type column sent_dt then your query should like

$query = mysql_query("SELECT sms_text FROM sms_in WHERE sent_dt = '2015-01-13' ");
Imran
  • 3,031
  • 4
  • 25
  • 41
M Reza Saberi
  • 7,134
  • 9
  • 47
  • 76