Thoughts caused by a Mysql statement _ MySQL-mysql tutorial

Source: Internet
Author: User
Thoughts on a Mysql statement bitsCN.com

Thoughts on a Mysql statement

Today, I saw a mysql statement written by my colleagues, but I didn't fully understand it. I suddenly felt the gap. in my mind, mysql statements only add, delete, query, and modify them, you can still write it like this.

[Php]

$ SQL = "SELECT category_general_table

FROM product_category

WHERE category_id IN

(SELECT DISTINCT

CAST (SUBSTRING (product_code, 1, 5) as unsigned) AS cid

FROM product_index

WHERE member_id = $ memberId AND shop_id = $ shopId )";

I have never written it like this CAST or SUBSTRI NG.

After checking the manual, another function CONVERT is similar to it.

Cast (value as type); Convert (value, type );

Not all types can be dropped. the type that can be converted is as follows:

Binary, with a BINARY prefix: binary

Character type, with parameters: CHAR ()

DATE: DATE

TIME: TIME

DATETIME type

Floating point: DECIMAL

Integer: SIGNED

UNSIGNED integer

It seems that I still have to read more manuals.

BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.