I’m joining 3 tables in SQL Server for the purpose of mapping users to their managers. The purpose of the junction table is to map their full usernames to their network ID. Here’s the query: The first 3 columns appear as I’d expect, showing the Network ID, Full User Name and the Manager’s Full Name. However, the 4th column is
Tag: join
How can I conditional join two tables to get results based on an evaluation (SQL Server)?
I have two tables in my database: Offices Positions How can I select all entries from Positions based on their Department and Section, but one above their level? I’m guessing I need a join with some kind of condition that gets evaluated to do this. For example, the Senior Dev position is at level 1. So, I would like for
is it violate 2NF?
My table book PK ID INT pfK langID INT title VARCHAR description MEDIUMTEXT releaseYear YEAR chaptersPrice DOUBLE thumbnail BLOB Where pfk – Primary-Foreign Key; {ID, langID} – PK; chaptersPrice – price of each chapter of book. Example: BookName1: chaptersPrice=2 BookName2: chaptersPrice=3 I think in this table some attributes are functionally dependent on the part of primary key (ID): {ID} ->
Simplification of SQL Query
SQL is not my specialty. I have a working query that accomplishes what I need it to, but I know there has got to be a cleaner way of accomplishing my goal. The query should return: – Name – Date of …
Select only products that are active via query from two tables
I have a query that provides me with a list of productId:s that I then match with a products table.. But how would I adjust the query to give me only productId:s that are active (active=1)? Answer You can use join:
Delete Rows which are fetched by a select query joining several tables
I have written the following select: What I want to do: I want to delete the rows in reminder, which are fetched by the described select. What I tried: Result: 00907. 00000 – “missing right parenthesis” I wonder if i can basically delete these rows in this manner. I also tried ‘exists’ resulting in the same error. Any suggestions? Thanks
SQL JOIN, all from t1 and all from t2 except what’s common to t1
I need all entries from Table A and all entries from Table B that are NOT common to table A. I have 6 common fields. How do I go with this? I tried select … from Table A left join Table B, it missed some values from Table A. Tried also right join, full join…Any pointers on how to do
MySQL Merge two queries based on mutual column
I have two queries that retrieve records from 2 different tables that are almost alike and I need to merge them together. Both have created_date which is of type datetime and I’m casting this column to date because I want to group and order them by date only, I don’t need the time. First query: Second query: What I need
How to delete a row from a relationship table using two columns
I’m trying to delete a relationship between table T2 and T3 that is on table T1. I’ve searched but I could only find examples of a DELETE with only one INNER JOIN. I’m trying something like this, but I get a error: SQL error: ORA-00933. 00000 – “SQL command not properly ended” How can I get this to work? Answer
Limit the results returned by MySQL join to 1
I’m doing a JOIN on two tables and the right side has multiple results for the ON clause: e.ID = ti.event_id. How do I limit the results returned by the join to 1? Sort of like LIMIT 1 events_detail …