Using SELECT SUBSTR - MySQL PHP

Posted by EM MAJ_COM On Sunday, September 30, 2012
I've got to re-learn my MySQL and PHP programming skills.

I have a field name contentdata with a hex data of AA560D72DA4AB20AAA using a type char.

In MySQL, I can run this command:
SELECT SUBSTR(hex(contentdata),15,2) FROM table1
output is: 0A

How can I code "SELECT SUBSTR(hex(contentdata),15,2) FROM table1" in PHP so I can bring the same result?

MySQL create php code gave me this recommendation but I can't show the value.
$sql = "SELECT SUBSTR(hex(payload),15,2) FROM device_status LIMIT"

Let me know what I'm missing here?

UPDATE:
A member (Katherine) in domain name forum recommended to use "AS hex_value" to create aliases for the field resulting from expressions. It works!

So, I query the data using the codes below:
"SELECT SUBSTR(hex(contentdata),15,2) AS myHex_data FROM table1"


Related Posts :



2 Response to "Using SELECT SUBSTR - MySQL PHP"

Post a Comment

First things first: Connect through one of the following social media tools below:
Enter your email address:
Subscribe to KING.NET by Email http://www.twitter.com/kingnet
http://www.randompage.com/profile/king
Moscom.com Web Hosting 24x7 Phone Support. The ultimate in performance, control, and convenience.

Get a Free Bitcoin

NeedName.com - Domain Name Registration and DNS Management.
Breeder.co - All about Pets.
Pet By OWner.
Moscom.com Web Hosting, SSL, Email, DomainName, and Dedicated Server.
For Ad Campaign, please send email to Support[@]Whaddya.com. Thank you.