Jump to content

[SOLVED] view that has two tables data


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

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.