Questions tagged [exists]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
5k views

How can I create a bool column for a view based on the result of a statement?

I'm using PostgreSQL as my database. CREATE TABLE groups ( id SERIAL NOT NULL, name TEXT NOT NULL, PRIMARY KEY (id), UNIQUE (name) ); CREATE TABLE users ( id ...
Bryan's user avatar
  • 397
0 votes
1 answer
90 views

IF EXISTS doesn't stop errors on RDS Postgres 11.19 instance

Recently one of our RDS Postgres databases was upgraded to version 11.19. Since then, we're receiving errors when running a database migration. I can't replicate this issue locally, it appears to be ...
Ben Hitchcock's user avatar
0 votes
2 answers
38 views

I have a database with a player, tournament, and registration table. I need to query all players that played in 2 types (attributes) of tournaments

I currently have two tournaments that have matches. Wimbledon and Atlanta open which I have one as a grand slam and the other as a masters 1000, and I want to get the players who played in both This ...
zaria palmer's user avatar
0 votes
1 answer
522 views

Select only those records that have same multiple values for a particular column if it's existing?

Below is an example of my pricing_supports table have more than 3 milions rows. There some rows having same values in the first_origin_id, delivery_id fields. If there're records with same ...
Dương Khoa's user avatar
0 votes
0 answers
63 views

Executing IF Exists condition

I have a sproc that scripts out permissions and in the process, I add a check to see if the object exists before dumping the results into a table. Then, I have another re-assign permissions sproc that ...
Laurent's user avatar
  • 73
0 votes
2 answers
3k views

Select Data from two tables ONLY IF ID on both tables are SAME

I need to select returns result SELECT wl.id FROM wishlist AS wl LEFT JOIN wishlist_products AS wp ON wl.id = wp.wishlist_id Only IF ALL of wp.product_id EXISTS in wishlist_products_bought....
andrei_sharov's user avatar
0 votes
2 answers
84 views

How to check if a record is linked with two or more values in a left join

In MySQL, I have a table of products connected with a different table with categories. I often show the list by making a LEFT JOIN and GROUPING the results: e.g. LEFT JOIN gives me: Name | Category ...
mesqueeb's user avatar
  • 189
0 votes
4 answers
91 views

How to visualize joins between inner queries to their respective outer queries?

I seem to always have trouble visualizing what the meaning is when an inner query is joined to it's outer query. Here's an example: SELECT NM.MovieId, NM.MovieTitle FROM NinjaMovies AS NM WHERE ...
J.D.'s user avatar
  • 35.2k
-1 votes
1 answer
37 views

How to check existence of a value in between two columns of the same table

I have a table bills having columns id, starting_bl_no, ending_bl_no. How can I check a new bill number input is already exist in the table? id starting_bl_no ending_bl_no 1 100 ...
Navaneet Raman Bhaskar's user avatar
-1 votes
2 answers
117 views

MYSQL get rows not axisting in other table

I have two tables with 1 identical data column for comparison. One table "species" is a wide list of species and each data row has one unique id called "suid" add. to its primary ...
BigMac's user avatar
  • 1

1
2