我需要SQL重复查询 [英] I need SQL in query with duplicates
问题描述
以下是sql查询:
Following is the sql query:
select SKU,PRODUCTNAME,PRODUCTVARIANT from tbl_product where SKU in(SELECT * FROM splitstring('ewew,slk,ewew'))
我需要获得3行(有重复),但在Query中只返回2行。
我能做些什么来获得3行?
谢谢
我的尝试:
现在,我只得到2行。
splitstring函数将字符串拆分为3行。
I need to get 3 rows(with duplicate) but in Query will return only 2 rows.
What can i do to get 3 rows?
THanks
What I have tried:
Right now, I'm getting only 2 rows.
The splitstring function is splitting the strings into 3 rows.
推荐答案
改为使用JOIN
:
Use aJOIN
instead:
select
P.SKU,
P.PRODUCTNAME,
P.PRODUCTVARIANT
from
tbl_product As P
INNER JOIN splitstring('ewew,slk,ewew') As S
ON S.VALUE = P.SKU
;
注意:您显然需要使用从<$返回的正确列名替换 S.VALUE
c $ c> splitstring function。
NB: You'll obviously need to replace S.VALUE
with the correct column name returned from your splitstring
function.
查询似乎没问题。
你能测试一下以下查询?
The query seem ok.
Can you test the following query?
select SKU,PRODUCTNAME,PRODUCTVARIANT from tbl_product where SKU in ('ewew','slk')
查询应生成三行。如果它仍然是两个意味着可能是tbl_product表上的数据问题。它可能是SKU上的额外空间或其他东西。
如果查询返回3行,可能表示splitstring函数可能是个问题。
The query should produce three rows. If it still two that mean that could be data issue on the tbl_product table. It could be extra space on the SKU or something.
If the query return 3 rows that could signal that the splitstring function might be an issue.
这篇关于我需要SQL重复查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!