I have a table called users
which looks like this:
+----+----------------+
| id | name |
+----+----------------+
| 1 | Blake |
| 2 | Jenn |
+----+----------------+
And i have a STREAM called transactions
which looks like this:
+----+----------------+----------------+
| id | sender | receiver |
+----+----------------+----------------+
| 1 | 1 | 2 |
| 2 | 2 | 1 |
+----+----------------+----------------+
So basicly what i want to end up with, looks kind of like this:
+----+----------------+----------------+----------------+----------------+
| id | sender | sender_name | receiver |receiver_name |
+----+----------------+----------------+----------------+----------------+
| 1 | 1 | Blake | 2 | Jenn |
| 2 | 2 | Jenn | 1 | Blake |
+----+----------------+----------------+----------------+----------------+
I've only managed to join the stream and the table partitioned by sender or either receiver, therefore i can only get either the sender info or the receiver info.
You can use two times JOIN with the users
table to get the expected result:
SELECT TR.id, TR.sender, SE.name AS sender_name, TR.receiver, RE.name AS receiver_name
FROM transactions TR
JOIN users SE ON SE.id = TR.sender
JOIN users RE ON RE.id = TR.receiver
the point is to create a stream to display that, i've tried that method you described actually but i think it does not work on ksql as it expects a ';' after the first inner join.
Statement: create stream userstransactionsjoinedfinal as select t.txid,t.sender,
up1.firstname as senderfirstname,up1.lastname as senderlastname,up1.phonenumber as
senderphonenumber,up1.email as senderemail,t.receiver,up2.firstname as
receiverfirstname,up2.lastname as receiverlastname,up2.phonenumber as
receiverphonenumber,up2.email as receiveremail, t.SENDERWALLETID,
t.RECEIVERWALLETID,t.status,t.type,t.amount,t.totalfee from transactionsrekeyed
inner join usersnow up1 on up1.id=t.sender inner join usersnow up2 on up2.id =
t.receiver;
Caused by: line 1:483: mismatched input 'inner' expecting ';'
Caused by: org.antlr.v4.runtime.InputMismatchException
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.