0

how to make the output like this? From 4 tables (rate, cost, tools, car)

|`RateID` | `Costing` | `Toolsfk` and `CarFK` |
|---------------------------------------------|
|    1    |    1000   |     1004              |
|    2    |    2000   |     2003              |

this is the tables

enter image description here

i want to 2 or more Foreignkey in 1 column, should I use CONCAT? but, as I know, CONCAT is for output only. So, what if for output and input data in database? just use Insert?

Ainal Yaqin
  • 31
  • 13

1 Answers1

0

polymorphic association is not possible, polymorphic association means single column has more than one foreign key for different tables. foreign key can target only one table at a time, a single column foreign key can't refer more than one tables, if u want to refer more than one table using single column then there are two ways..

1- creating identical table of referenced table 2- use two columns in a table, one column refer tools table and one column refer car table

below is a link from where you can take refrence

(Possible to do a MySQL foreign key to one of two possible tables?)