Request MySQL 2 table row query statement

Source: Internet
Author: User
Ask MySQL 2 tables to query the statement together.
This post was last edited by Dxmbxh6 on 2014-06-13 14:14:55

Table A
ID Time Title
1 2014-05-01 aaaaaaaaaaaa
2 2014-05-02 bbbbbbbbbbbbb
3

b table
ID Time URL
1 2014-05-03 CCCCCCCCCCCCCCCCCCCCCC
2 2014-05-04 ddddddddddddddddddd
3 2014-05-05 eeeeeeeeeeeeeeeeeee
4 2014-05-06 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

The desired result

Type ID Date title
A 1 2014-05-01 aaaaaaaaaaaa
B 1 2014-05-03 CCCCCCCCCCCCCCCCCCCCCC
B 2 2014-05-04 ddddddddddddddddddd
B 3 2014-05-05 eeeeeeeeeeeeeeeeeee
------Solution--------------------
There is a problem with the design of this table. Can't be achieved.
------Solution--------------------
The Type field of the result is not in two tables, where does it come from?
------Solution--------------------



Select ' B ' as tname, ID, time
ORDER BY 2,1

------Solution--------------------
Don't see what logically album
Why is the id=2 of a table and the id=4 record of B table to be erased?
  • 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.