Skip to content
Advertisement

Tag: database

Update table to make primary key out of two foreign keys

Have a table sample_tag which already exists with 1000’s of entries. It consists of two foreign keys, sample_id and tag_id. However, the database is allowing duplicate sample_id/tag_id records to be created. Without creating a new table, is there a SQL statement to update the sample_tag table such that the two foreign keys, together, function as its primary key? Database is

Update Multiple Values in a SQL query based on row values

Is there a possible way only use SQL Update query to update July Data to August data? E.g. The Value of B in July should be updated to 12. Dimension Key is the primary key and Name is the “durable” key. CURSOR is allowed to use but not preferred. Answer You must join the table to itself to set different

Can a backticked identifier have a backtick in it?

Is it possible to escape a SQL identifier in either MySQL or BigQuery or any other RDBMS that allows quoting of identifiers with the ` character? For example: Works, but then How would I add a literal backtick to it, or is that just not allowed? Answer Yes. Use a doubled backtick, eg: This is similar syntax for including quotes

Only count SQL entry if two rows (as a pair) have the needed conditions

How can I only count the “Great” per “Country” in this SQL table? My table “commentmeta” comment_id meta_key meta_value 540 Voting Great 540 Country UK 560 Voting Great 560 Country PL 610 Voting Bad 610 Country UK 630 Voting Great 630 Country UK The result should be UK: 2 times “Great”, PL: 1 time “Great” With something like this I

Restrict “subcategory” based on other “category” column

I’m creating a SQLite database where I have 3 tables: transactions, categories, sub-categories in the transactions table, there is a column “category” with a foreign key to the categories table in the sub-categories table, there is column “parent-category” with a foreign key to the categories table Now, how can I ensure that the sub-category that I fill in with transactions

What do you call the . syntax in SQL?

In many databases, when writing a SELECT query, you can provide the database name along with the table name in order to resolve any ambiguity the database might encounter in case there are multiple databases with the same table names. For example, let’s say the user currently logged into SQL Server has SELECT privileges on databases DB1 and DB2, and

Microsoft Azure database admin user creation

I deployed azure MySQL 5.7 database in azure. I can’t create another admin user with admin permission with the serveradmin login. When I tried below command GRANT ALL PRIVILEGES ON . TO ‘sammy’@’localhost’ WITH GRANT OPTION; I am getting error serveradmin@ip don’t have enough permissions even though I am user server admin login. Is this because of Microsoft Azure database

Advertisement