Query all records
Hello everyone, I hope you are well. I have an order database table with a line_items field which is a list of objects. These objects contain the field product_id. I then want to query all order records where line_items has an item with product_id=xxx.
How can I do this? I haven't found any filters to help me (most seem to be restricted for query operations).
Best Answer
-
Hi @Leo Med. If this object will ultimately only contain one field, it is definitely less complex (and comes with less overhead) to just use a list of table references instead, so that is the recommended approach.
That being said, if you did want to keep it as an object, you'd utilize a JOIN instead. Here's a quick video example. Let me know if this makes sense.
Answers
-
I found that a custom query using the following syntax might help:
WHERE input:product_id IN databaseName.line_items
line_items being a field which can accommodate a list of integers (rather than a list of JSON objects as you might have at the moment).
Hope that helps
-
I thought about that, but it doesn't make sense to me for the line_items to be a list of integers. But if that's the only way to do it, I'll create a new field and migrate all the necessary data to that field.
Any other solution would be welcome. Thanks tho! @ribotmaximus
-
🎉 That's it, that's wonderfull @Chris Coleman , thank you a lot🙏.
-
Hey @Chris Coleman , I'm back, with another one. Is there any we can go deeper in joining tables ?
Like I also want to query my table based on a particular store the product is sold from.
Is it directly possible ?
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback