我有两个表员工和订单,其中emp-id(字段)在两个表中都很常见。我需要获取emp-name和emp-ph形式的employee表,以及order-num来自order table.how链接这些表并获取值
define variable c as integer.
define query q1 for customer,order SCROLLING.
INPUT FROM Value ( "C:\src\New folder\cnum.txt").
IMPORT c.
open query q1 for each employee where employee.emp-id=c ,
each order where (order.emp-id = employee.emp-id ).
从查询浏览使用
引发错误
答案 0 :(得分:0)
您需要为两个表定义查询:
DEFINE QUERY q1 FOR Customer, Order SCROLLING.
答案 1 :(得分:0)
您的要求未提及客户表,也不需要文件输入,因此我将重点关注您所说的内容:
for each employee no-lock,
each order no-lock where order.emp-id = employee.emp-id:
display employee.name employee.emp-ph order.order-num.
end.
答案 2 :(得分:0)
如果您尝试从文本文件中获取员工ID,则应执行此操作。它会读取文件每一行的ID,找到员工记录并显示订单信息。
DEFINE VARIABLE c AS INTEGER NO-UNDO.
INPUT FROM VALUE("C:\src\New folder\cnum.txt").
REPEAT:
IMPORT c.
FIND FIRST Employee WHERE Employee.Emp-ID = c NO-LOCK NO-ERROR.
IF NOT AVAILABLE(Employee) THEN
DO:
MESSAGE "Cannot find employee with ID " c VIEW-AS ALERT-BOX ERROR.
NEXT.
END.
FOR EACH Order NO-LOCK WHERE Order.Emp-ID = Employee.Emp-ID:
DISPLAY
Employee.Emp-Name
Employee.Emp-Ph
Order.Order-Num.
END.
END.
INPUT CLOSE.