Skip to content

Tag: sql

Firebird SQL Statement to Get the Table Definition

I am writing my own Firebird database browser using the ibpp library. Is there a way I can get the table definition using an SQL statement? Answer Firebird does not support schemas, so there is no way you can get that information. The closest thing might be the owner, which you can get by querying RDB$RELATIO…

Duplicate Rows on SQL Join

When I do a left join on a table it duplicates the results from the left table when more values are found in the right table. How can I only return the distinct values from the left even when there are multiple values on the right table. (return only the one movie even when there are multiple images on the

Difference between count(attribute) and count (*) using group by

I haven’t understood the difference between count(*) and count having an attribute as argument. Here I make an example: there are two relationships: With employee_ssn which references employee(ssn) and project_id referencing project(id). Primary keys: project(id), employee(ssn), working_on (employee_ssn…

How to convert all tables in database to one collation?

I’m getting error: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation ‘=’” I tried changing both tables manually to utf8_general_ci,IMPLICIT but I’m still getting the error. Is there a way to convert all tables to utf8_general_ci,IMPLICIT …

SQL query, where = value of another table

I want to make a query that simply makes this, this may sound really dumb but i made a lot of research and couldn’t understand nothing. Imagine that i have two tables (table1 and table2) and two columns (table1.column1 and table2.column2). What i want to make is basically this: I don’t know if thi…

Combine two statements with LIMITS using UNION

Is there a way to combine these two statements into one without having duplicate entries? My first, obvious attempt is not supported by SQLITE (Syntax error: Limit clause should come after UNION not before): Answer Use subqueries and perform the limit within them.