Hello i am trying to prepare tree structure with MySql, tables look something like this. My Question is: Is it possible to do left join and sort columns by name, but if in lang is eq to “fra” return that row with that name, otherwise return “eng” name. Pseudo code So final result will be something like this, in total
Tag: left-join
How to display the total count of the last row by filestatus?
I have to display the total count of the last row by filestatus. tbl_bankdata tbl_fileStatus I have two tables tbl_bankdata and tbl_fileStatus. I am sending bank_id in the tbl_fileStatus as a f_bank_id. Now I have to show the last f_bankid count. For example, I have to fetch the count where f_filestatus=1. so my output will be 0. Why 0 because
Simple PostgreSQL Self Join
This is what my employee table looks like where manager_id is Foreign Key to the same table it references to employee_id and indicates which employee has manager and who is. I did self left join and the result was what was expected. But this query gives me So I don’t understand why it returns something instead of nothing.employee_id will never
Return in which or statement results are from SQL [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 1 year ago. Improve this question I’m having the following SQL statement, to return worksheets that teachers have liked, and worksheets that teachers made by themselves. It’s working fine, but now
Getting sum of two rows in an inner joined table
I have these two tables; trips id date revenue 1 01/01/2020 5000 2 01/01/2020 3000 3 02/01/2020 4000 4 02/01/2020 2000 expenses id tripid amount 1 1 500 2 1 300 3 2 400 4 2 200 5 2 700 I would like to get the sum of revenue collected in a day AND sum of expenses in a day.
select conditionally with conditional joins in mysql
I am trying to join two tables, people and sales, and displaying results based on a where condition which should be used to join the tables. My current attempt is showing only one result but I want all the rows in the people to be shown regardless of whether they have a record in the sales table, if they have
Can you use ORDER BY (column) LIMIT with a secondary column?
I want to find out the Top 10 rented movies in the sakila db. It must be sorted DESC after total_rentals and secondary after film title. My solution looks like this and works so far without the film …
Create temporary table to display missing months from query
I am trying to create a simple MySQL query to get the sales data for each month of the year, grouped by monthname and SalesName. CREATE TEMPORARY TABLE Cal (monthid INT, monthname VARCHAR(50)); INSERT …
How do I join two tables from a database in SQL?
I’m currently working on a project where we have to join two tables in SQL and then create a page to show the result of the two tables combined. This is what I have so far: SELECT * FROM ANIMAL …
SQL query to get subtotal on the last row of bill number
I have written the following SQL query which gives the result not in a way I desire. The only change I want is that, I don’t want to repeat the subtotal on every single line, which is what my query is …