简体   繁体   中英

how do i select the same row from one table for different values in another table + sql

Table values are as below

table 1

edition
-------
2001       
2002
2003

table 2

productid |  shortname
----------------------
185       |  jtic

The result should be

2001          185          jtic 
2002          185          jtic
2003          185          jtic

How can I achieve this? Tried with some joins . But not able to get it. As I am not a database developer, finding it hard. Can someone help?

Use CROSS JOIN method :

  SELECT edition , productid ,  shortname
  FROM table1
  CROSS JOIN table2

In addition to Mansoors answer you can also use a shorter syntax:

SELECT edition , productid ,  shortname
FROM table1, table2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM