SQL statement records, SQL statements

Source: Internet
Author: User

SQL statement records, SQL statements

Query all surgical appointments and the corresponding schedule. If the pk is not null, separate them with commas ). The SQL statement in mysql is as follows:

Select distinct. pk,. surgeryName,. clerkName,. customerName,. orderTime, B. forecastTime, B. pk surgery_pk, case when c. pk is not null then (select group_concat (d. pk) from surgery_arrange d where d. surgery_order_fk =. pk) else null end surgery_arrange_pk from (surgery_order a left join surgery B on. surgery_fk = B. pk) left join surgery_arrange c on. pk = c. surgery_order_fk order by surgery_arrange_pk desc,. orderTime asc limit 0, 10

The result is shown in:


Related Article

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.