consider the following table
考虑下表
id Part_no cust. work_order
1 abc xyz 111
2 abc xyz 123
3 abc xyz 121
4 qqq xyz 222
Now when I enter a particular work order I want the following display.
现在,当我输入特定的工单时,我想要以下显示。
part_no cust work_order
abc xyz 111
abc xyz 123
abc xyz 121
3 个解决方案
#1
0
@Wyatt Shipman's answer should work. Here's another way to do it:
@Wyatt Shipman的答案应该有效。这是另一种方法:
select a.part_no, a.cust, a.work_order from thetable as a
inner join thetable as b on a.part_no = b.part_no
where a.work_order = 111;
SQL小提琴
#2
0
You can use a select query to create a list like below
您可以使用选择查询来创建如下所示的列表
SELECT Part_No, Cust, Work_Order
FROM tblA a
WHERE a.Part_No in (SELECT ai.Part_No from tblA ai where a.workorder=111)
#3
0
If you use mysql You can force a specific order by based an value for a fields
如果使用mysql您可以通过基于字段的值强制执行特定订单
select part_no, cust, work_order
from your_table
where part_no = 'abc'
order by FIELD(work_order,111,123,121);
for Oracle yuo can use decode
对于Oracle yuo可以使用解码
select part_no, cust, work_order
from your_table
where part_no = 'abc'
order by decode(work_order,111,1, 123,2,121,3);
(could be doesn't make sense but you can do it)
(可能没有意义,但你可以做到)
#1
0
@Wyatt Shipman's answer should work. Here's another way to do it:
@Wyatt Shipman的答案应该有效。这是另一种方法:
select a.part_no, a.cust, a.work_order from thetable as a
inner join thetable as b on a.part_no = b.part_no
where a.work_order = 111;
SQL小提琴
#2
0
You can use a select query to create a list like below
您可以使用选择查询来创建如下所示的列表
SELECT Part_No, Cust, Work_Order
FROM tblA a
WHERE a.Part_No in (SELECT ai.Part_No from tblA ai where a.workorder=111)
#3
0
If you use mysql You can force a specific order by based an value for a fields
如果使用mysql您可以通过基于字段的值强制执行特定订单
select part_no, cust, work_order
from your_table
where part_no = 'abc'
order by FIELD(work_order,111,123,121);
for Oracle yuo can use decode
对于Oracle yuo可以使用解码
select part_no, cust, work_order
from your_table
where part_no = 'abc'
order by decode(work_order,111,1, 123,2,121,3);
(could be doesn't make sense but you can do it)
(可能没有意义,但你可以做到)