sql query on line

sql editor online
online oracle sql editor
online sql terminal
sql online practice test
sql formatter online
sql fiddle
sql editor free
sqlite online

I have one SQL table There are entries

+-----------------+------+
| idanother_table | Col1 |
+-----------------+------+
|              11 |   50 |
|              11 |   61 |
|              11 |   62 |
|              12 |   61 |
|              12 |   62 |
|              13 |   50 |
|              13 |   65 |
+-----------------+------+

I want a query that gives this result

+-----------------+------+
| idanother_table | Col1 |
+-----------------+------+
|              11 |   50 |
|              11 |   61 |
|              11 |   62 |
|              13 |   50 |
|              13 |   65 |
+-----------------+------+

So get all lines related to id_anothertable and col1 = 50.

So when for an id we have col1=50, we take all lines related to that id

Maybe this problem is a duplicate of another, but really i don't know how to name my problem so i have any base for research

You can try to use IN

SELECT * FROM t 
WHERE idanother_table IN 
(
    SELECT idanother_table 
    FROM t
    where Col1 = 50
)

or exists

SELECT * 
FROM t t1 
WHERE exists
(
    SELECT 1 
    FROM t tt
    where tt.Col1 = 50 and t1.idanother_table = tt.idanother_table
)

How can I run SQL server queries online without installing?, Dark Theme available. Click on " " icon near execute button and select dark theme. You can embed code from JDoodle  Online Sqlite Compiler, Online Sqlite Editor, Online Sqlite IDE, Sqlite Coding Online, Practice Sqlite Online, Execute Sqlite Online, Compile Sqlite Online, Run Sqlite Online, Online Sqlite Interpreter, Execute SQL Online (SQLite v3.20.1)

you could use a join on subquery for col1 = 50 retuning idanother_table

select * from my_table 
inner join (
    select  idanother_table 
    from my_table  
    where col1 = 50  
) t on t.idanother_table = my_table.idanother_table 

Online SQL Editor - Online SQL Scripting, Check SQL query syntax online, validate SQL queries, compile SQL queries to check for syntax errors. All major databases supported: MySQL, SQL Server,  W3Schools has created an SQL database in your browser. The menu to the right displays the database, and will reflect any changes. Feel free to experiment with any SQL statement.

You can use exists

SELECT t1.* FROM t t1
WHERE exists
(
    SELECT 1 
    FROM  t2
    where t1.idanother_table =t2.idanother_table and t2.Col1 = 50
)

SQL Syntax Check Online, SQL Validator, Instant SQL Compiler , Online Sqlite Compiler, Online Sqlite Editor, Online Sqlite IDE, Sqlite Coding Online, Practice Sqlite Compile Sqlite Online, Run Sqlite Online, Online Sqlite Interpreter, Execute SQL Online (SQLite v3.20.1) SELECT * FROM NAMES;. Free online SQL Formatter for SQL Server - Beautify SQL statements instantly and convert code into well formatted script. Powered by Devart's SQL Complete.

I'd use the exists operator on a query that checks for col1 = 50:

SELECT *
FROM   mytable a
WHERE  EXISTS (SELECT *
               FROM   mytable b
               WHERE  a.idanother_table = b.idanother_table AND
                      b.col1 = 50)

Online Sqlite Compiler - Online Sqlite Editor, Change first word "SELECT" to "LINE-SELECT" SELECT LINE-SELECT ​ -- labels - first column -- values - all columns 2..N -- color column key - "_c":  GUI Code Viewer is Edit Area © by Christophe Dolivet

SELECT idanother_table, Col1 
FROM YourTable 
WHERE idanother_table IN (SELECT idanother_table 
    FROM YourTable 
    WHERE Col1=50
)

SQL Online IDE, Formats any SQL query with your desired indentation level, even if your SQL statement is invalid. You can modify the case of the SQL keywords and identifiers to  This unique introductory SQL tutorial not only provides easy-to-understand SQL instructions, but it allows you to practice what you learn using the on-line SQL interpreter. You will receive immediate results after submitting your SQL commands. You will be able to create your own unique tables as well as perform selects, inserts, updates

Free Online SQL Formatter, Introduction to SQL. This tutorial provides an introduction to the Structured Query Language (SQL), learn how to create tables with primary keys, columns,  Free online sql formatting tool, beautify sql code instantly for SQL Server, Oracle, DB2, MySQL, Sybase, Access and MDX

Oracle Live SQL, How to connect to the server and execute SQL statements. Programming with SQL: [ SQL in perl on the Web | SQL from Java ]; Error Messages: Some error  1. For each table used in SQL query, insert a table script in input field. 2. At the end of each script write a char ";" - it is a separator. 3. Do NOT use a SCHEMA names. 4. Insert a SQL query and click a Execute SQL button

SQLZOO, This online test requires candidates to write SQL queries that extract, combine, and manipulate data. Recommended Job Roles. Data Analyst. Database  To turn off the line number feature in SQL Server Management Studio you need to navigate to Tools | Options | Text Editor | General | Display and uncheck the Line Number check box and click the OK button to save the changes so that next time you open a new query window in SSMS line numbers will not be displayed.

Comments
  • Show us db schema, sample data, current and expected output. Please read How-to-Ask And here is a great place to START to learn how improve your question quality and get better answers.
  • i would use the IN query, MySQL tends to optimize badly when using co-related subqueries.