Home > database >  Great god technical guidance for the younger brother of two tables, consolidated the query results
Great god technical guidance for the younger brother of two tables, consolidated the query results

Time:10-04

Need to query data merging two tables, but there are requirements on the format, and the data is correct, so I only when the query to query a id, if you want to query so id data, how to implement, please teach a great god, the following is rendering:

CodePudding user response:

Query all the data? Remove the behind the where ywid='conditions? I mean what do you mean?

CodePudding user response:

Using variables, and constants, in you, there is no difference between; Use can directly;

CodePudding user response:

reference 1st floor js14982 response:
query all data? Remove the behind the where ywid='conditions? I mean what do you mean?


Yes, is not just a ywid data, is the first line is the main table data format requirements, below is the detailed data,

CodePudding user response:

refer to the second floor wmxcn2000 response:
using variables, and with a constant, in here, you little difference; Use can directly;



Used directly, query the data format is wrong, all data will be the main table, child table of all the data in the merger is not desired effect
Want to effect corresponds to the same id is a data, the main table after more than child table data like this effect,

CodePudding user response:

Wait for god to come to

CodePudding user response:

reference 4 floor sinat_33564156 response:
Quote: refer to the second floor wmxcn2000 response:

Using variables, and constants, in you, there is no difference between; Use can directly;



Used directly, query the data format is wrong, all data will be the main table, child table of all the data in the merger is not desired effect
Want to effect corresponds to the same id is a data, the main table after more than child table data like this effect,


Do you want to be a the records, here are 10 note table records, article 2. The records below again, next is the second child records of the records?


Such ideas

Select mids, 0 as sid from m - the main table records, add a column, as the child table ID 0, so that we can ensure that the row in the child table records before
Union all
Select mids, sid from s - child table
The order by 1, 2, according to the main table row first, and then according to the child table row

CodePudding user response:

Grouping with subtotal function, should be able to meet the demand of your group by grouping sets ((" Lord grouping conditions ", "secondary grouping conditions"), the main branch conditions)
  • Related