Home > database >  Mysql three tables, according to the return value of the main table, determine the choice that table
Mysql three tables, according to the return value of the main table, determine the choice that table

Time:10-07

The select case truck. TransStatus
When 'OnWay then (select app. Lng, app. Lat from Mem_TrackApp app)
The else (select c.a. reaFrom, c.a. reaTo from CargoSource c) end
The from Mem_Truck truck
As the main table is Mem_Truck I think according to Mem_Truck TransStatus values to determine I will query CargoSource or Mem_TrackApp, look at, the associative table is not the same as the returned column value is different also, here TransStatus' OnWay 'and' Other 'two values, not very familiar with SQL, genuflect is begged online posts are basic options in case the when, but the case.. When it seems the return is the same target columns, is not consistent with what my business logic,

CodePudding user response:

Reference, the
but case.. When it seems the return is the same target columns, is not consistent with what my business logic,


Meet the business logic of the building Lord what different? Suggest a more detailed description,

Reference
suggest you list your table structure, and provide the test data, and based on these test data that corresponds to the correct result,
Refer to the way the post questions http://bbs.csdn.net/topics/320211382

1. You create table XXX.. Statement
2. You insert into XXX... Statement
3. The result is what kind, and give a simple algorithm description)
4. Do you use the database name and version of (often asked in MS SQL server edition MySQL)

So people who want to help you to build the same environment with you directly, and in providing the test before, avoid the error in the text understanding,

CodePudding user response:

reference 1st floor ACMAIN_CHM response:
,
reference
but case.. When it seems the return is the same target columns, is not consistent with what my business logic,


Meet the business logic of the building Lord what different? Suggest a more detailed description,

Quote:
suggest you list your table structure, and provide the test data, and based on these test data that corresponds to the correct result,
Refer to the way the post questions http://bbs.csdn.net/topics/320211382

1. You create table XXX.. Statement
2. You insert into XXX... Statement
3. The result is what kind, and give a simple algorithm description)
4. Do you use the database name and version of (often asked in MS SQL server edition MySQL)

So people who want to help you to build the same environment with you directly, and in providing the test before, avoid the error in the text understanding,



reference 1st floor ACMAIN_CHM response:
,
reference
but case.. When it seems the return is the same target columns, is not consistent with what my business logic,


Meet the business logic of the building Lord what different? Suggest a more detailed description,

Quote:
suggest you list your table structure, and provide the test data, and based on these test data that corresponds to the correct result,
Refer to the way the post questions http://bbs.csdn.net/topics/320211382

1. You create table XXX.. Statement
2. You insert into XXX... Statement
3. The result is what kind, and give a simple algorithm description)
4. Do you use the database name and version of (often asked in MS SQL server edition MySQL)

So people who want to help you to build the same environment with you directly, and in providing the test before, avoid the error in the text understanding,
Shanghai, mysql, you send this post I have ever seen, my understanding is that it is the main table to choose to link the two from the table, no matter choose which a table to link the returned column values are consistent, and return is a column, my business needs now is to choose the link table, returned to field are inconsistent, so...

CodePudding user response:

Business logic for such as: I empty condition and transportation condition, take the origin and destination of the associated table is consistent, if it is transportation condition, origin and destination is clear, can be directly linked table to collect, if it is empty, I can only transport routes related history, id take take to the inside of the area, then correlation area table to collect the origin and destination,
  • Related