I have been trying to figure out how I can combine multiple values to see if one of them returns True then it exists. Meaning that if A is True and B is False = Return True. If both are False then of course we return = False.
What I have currently done is:
dict_tuple = {"type": "fruit", "link": link, "store": store}
sql_query = "SELECT store, link FROM public.fruit_urls WHERE link_type=%(type)s AND link=%(link)s AND store=%(store)s union SELECT store, link FROM public.store_items WHERE link=%(link)s AND store=%(store)s"
which seems to work but I would like to convert the query to use exists instead since I do check if its in the database or not.
I managed to solve to do one check:
sql_query = "SELECT EXISTS (SELECT store, link FROM public.store_items WHERE link=%(link)s AND store=%(store)s)"
but how can I combine both
"SELECT EXISTS (SELECT store, link FROM public.store_items WHERE link=%(link)s AND store=%(store)s)""SELECT store, link FROM public.manual_urls WHERE link_type=%(type)s AND link=%(link)s AND store=%(store)s"
together and then return if one of them are in the database or not
select exists(...)around your initialUNIONquery.SELECT EXISTS ("SELECT store, link FROM public.fruit_urls WHERE link_type=%(type)s AND link=%(link)s AND store=%(store)s union SELECT store, link FROM public.store_items WHERE link=%(link)s AND store=%(store)s")? @VadimLanda