0

Table Name Products

+-----+-------------+-----------+----------+-----------+
| ID  | productCode | name      | quantity | SupplierID|
+-----+-------------+-----------+----------+-----------+
|  1  | PEN         | Pen Black |     2000 |    1, 5,  |
+-----+-------------+-----------+----------+-----------+
|  2  | BOOK        |  Red Man  |     270  |   2, 3, 5 |
+-----+-------------+-----------+----------+-----------+

Table Name Supplier

+-----+-------------+----------------------------+--------------+----------+
|ID   | SupplierCode|             name           |  address     | approved |
+-----+-------------+----------------------------+--------------+----------+
| 1   | MAL         |Merit Accessories LTD.      |  Dhaka, BD   |     Y    |
+-----+-------------+-----------------+----------+--------------+----------+
| 2   | IOL         |Intelligent Publishers LTD. |  Dhaka, BD   |     Y    |
+-----+-------------+-----------------+----------+--------------+----------+
| 3   | CPL         |Crypt Publishers LTD.       |  Delhi, IN   |     Y    |
+-----+-------------+-----------------+----------+--------------+----------+
| 4   | IPH         |Iris Publishers House.      |  Dhaka, BD   |     N    |
+-----+-------------+-----------------+----------+--------------+----------+
| 5   | RAPL        |Rume Acc. & Pub's LTD.      |  Gazipur, BD |     Y    |
+-----+-------------+-----------------+----------+--------------+----------+

So, now I want to join table Products and table Supplier as like as below so that all SupplierID one colomn can show all Suppliers list in result-

SELECT Products.* FROM Products
INNER JOIN Supplier ON Products.SupplierID=Supplier.ID;

Chris Li
  • 2,628
  • 1
  • 8
  • 23
  • Possible duplicate of [Is storing a delimited list in a database column really that bad?](https://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad) – Madhur Bhaiya Sep 25 '18 at 04:57
  • Please **normalize** your tables. It is a very bad and unscalable practice to stores comma separated values in a column. Anyways, if you still need a solution, check `FIND_IN_SET` function. What is your expected sample output ? – Madhur Bhaiya Sep 25 '18 at 04:59

0 Answers0