Let’s say I have two MySQL tables: table1 (templates) Columns: id_template, name, col3, col4, … table2 (aliases) Columns: id_alias, id_template_orig, id_user, alias I want to select a row from the table1 (templates) including all the columns (*). In the same select statement I want to check if current user has saved an alias for the original template name in the
Tag: select
SQL Informix advanced query
Let me try to explain what I want to do with my data. Structure of my data is as follows: I have 3 columns: date, id, and stage. Stages can be different numbers, but I’m interested in showing specific transition of some id from stage -1 to stage 1. Please see the example below. I have an id that was
How can I count number of appearance of a value and make it into a new column when querying? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I have a table like this ProductID | SalesOrderNumber 1 | SO0001 2 | SO0002 3 | SO0001 4 | SO0001 5 | SO0002 I
SQL: select 3 values and count how many times they are different
Say that you need to query some data and that there are three fields like the following (this is part of a larger query): Field1, Field2, Field3. So you select them like this: I need to compare these values and return the variable Result that is computed as follows: 0 if they are all the same 1/2 if two are
SQL How to select from multiple values in joined table
I have two tables A and B joined with a common id field. Table A has single entries per id. Table B has multiple entries per id. Table B has two columns “name” and “customertype”. …
Query to obtain value among selected values in a comma separated varchar
I have an SQL table as given below How can I write a Select query such that all titles with genre “Crime” will be displayed Answer First, you should fix your data model! Storing multiple values in a column is a really, really, really bad idea. That said, sometimes we are stuck with other people’s really, really, really bad decisions.
Get TOP 1 row from multiple tables based on date
I have five tables in a SQL Server database. These tables are listed below and I want to select Data from these tables according to date. I tried searching but could not find solution for multiple tables. Please help TABLE1 TABLE2 TABLE3 TABLE4 TABLE5 I want to select Label and Date from Table 3, 4 and 5 where Date is
Query to check if MySQL database is connected
I am wondering if there is a best practice or standard query used to check if a MySQL database is still connected? I was originally thinking of performing a simple search in one of my tables, which will confirm if the database is still there. Just wondering if there is a better approach. Answer No need to actually select from
MySQL Select all from Table 1 where Foreign key not exists or is not equal to specified key
Hello I can’t figure out how to write this select statement. I have the following schema: table 1 1:n table 2 n:1 table 3 So I got a n:m between table 1 and 3 what I want to do now is get all entries in table 1 that either don’t have an relation to table 3 via table 2 or
SELECT statement to remove empty columns from resultset with variable data
I’ve got a table that has been imported from a CSV as a midstep to gather data into other tables. All columns in this table may be empty but as long as one column has data, is a valid row. Because of this, there may be full rows with empty data, that are not valid to take into consideration. Here’s