on-internet
← Community

Get items that pattern matches another table's item title

Stack Overflow ·

I have this API which should get all items from Item table that pattern matches in WantedItem table that Item.item_id doesn’t exist in Table_3.item_id. @app.get("/wanted_items/{user_id}") def all_wanted_items(*, session: Session = Depends(get_session), user_id: UUID): get_all_items = session.exec( select(Item, WantedItem, Table_3) .where(WantedItem.user_id == user_id) .where(Item.item_id != Table_3.item_id) .where(col(Item.title).ilike(f"%{WantedItem.title}%")) ).all() if not get_all_items : raise HTTPException( status_code=404, detail="Some content", ) return [ { "item": item.model_dump(), "w

Comments

Sign in or sign up to comment and upvote.

No comments yet.