Jump to content

[SOLVED] view that has two tables data


isaac_cm

Recommended Posts

Hello,

I need to create a view that get data from two tables like this

 

table_size

-------------

10

12

14

16

 

table_color

------------

Red

Blue

White

Yellow

 

result_view (ordered by size table)

------------------------------------

10 - Red

10 - Blue

10 - White

10 - Yellow

12 - Red

12 - Blue

12 - White

12 - Yellow

etc

.

.

.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/70145-solved-view-that-has-two-tables-data/
Share on other sites

I cant modify my post and I forgot that all the data is in one table like that

 

table1

-----------------

type_id      value

1                10

1                12

1                14

2                Red

2                Blue

2                white

 

I need to combine the data like this

 

result_view (ordered by size table)

------------------------------------

10 - Red

10 - Blue

10 - White

10 - Yellow

12 - Red

12 - Blue

12 - White

12 - Yellow

etc

.

.

.

 

thanks

some of them has type_id = 1 and others has type_id = 2 , thanks I found a solution with a friend help Alan Larkin

 

SELECT distinct concat(t1.value, '-', t2.value) as attr,

t1.type_id FROM

table1 AS t1 INNER JOIN table1 AS t2

ON t1.type_id + 1 = t2.type_id

 

thanks for your effort

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.