MySQL Joining a Table twice - mysql

I have this Table:
Table Fluege
and I need to Create a VIEW "Umsteigeverbindungen" with the following colums:
Final Schema
In the first table I have a list of Flights from different airports. And the task is to create a view that shows all the possible "flight-connections" with only one stopover.
for example:
flying from FRA stoping over in DUB and finally landing in LAX.
That is all I have:
my try
I have no idea how to solve this problem. I would really appreciate if somebody can help me fixing this problem.
Thanks

SUM does not take two parameters like you did in sum(fleuge1.Preis,fleuge2.Preis)
sum is an aggregate function , meant to sum all the values on a column, if you want to sum two values from a two distinct sets just do fleuge1.Preis+fleuge2.Preis
if you want to post errors on stack overflow you can just copy them

Related

how can i put multiple records into 1 record in mysql

I was trying to move multiple records from one table to one record in another. with MYSQL,I tried Group_concat(), Concat() Group by, and Stored Procedure to breakdown the data and regroup. Unfortunately, my attempts have failed. I know you can help me because you are the experts. I thank you in advance. Please see image I attached.
Probably you require aggregation here, something like:
select Matrial, max(Qty_In_Jan) Qty_In_Jan, max(Qty_In_feb) Qty_In_feb....
from t
group by Matrial;

Pulling dimension from another fact table in SSRS Dax query

I have two fact tables. I would like to pull columns from a dimension which is part of another fact table using Dax query. The table is coming from a tabular cube. So far I have tried:
EVALUATE
SUMMARIZE(
'vwFCML'
,'Vessel'[VName]
,'Port'[PCountry]
,'PO'[Type]
)
Vessel[VName] and Port[PCountry] dimensions are from the vwFCML fact table while the PO[Type] is from another fact table called OrdTable. I get the error
The column 'Type' specified in the 'SUMMARIZE' function was not found in the input table
I am new to dax and any help would be greatly appreciated, thank you in advance.
This issue happens if the table listed in summarize section has no relation to other tables.
In your case, there is a possibility that the vwFCML table has no relation with PO table.
If you have another table, e.g. Dim_Vessel that is somehow linked to both vwFCML and PO, try using that as the summarize table (even if you are not using any column from that table at all).
e.g.
EVALUATE
SUMMARIZE(
'Dim_Vessel'
,'Vessel'[VName]
,'Port'[PCountry]
,'PO'[Type]
,....
)
Hope this make some sense?

How inefficient would this query be and also table structure?

I have two tables. One table stores course_updates, which basically has a new row pushed to it everytime someone adds or drops a course. I also have another table follower_updates that has a record pushed to it whenever someone follows someone. I want to be able to get the information for the logged in user, but I'm unsure how I should detect which table the information is coming from being that I want to display the information based upon which table it is from. Should I make a new column that update_type, or should I have a different method?
I'm also going to show what I'm thinking relatively in terms of sql. It won't be perfect because I haven't tested it yet. This is just a sample. I didn't want to bring in my current query because just the course_updates already has three inner joins and an outerjoin, so I tried to streamline the content for this question. thanks!
SELECT * FROM course_updates WHERE (establishes connection
enter code herebetween user and courses and followers)
UNION SELECT * FROM follower_updates WHERE followee.id = currentUser.id etc.
Don't use a UNION. Use two separate queries instead.

MySQL query - single product with multiple reviews

Thank you in advance for any help you may be able to offer!
I'm working with an a bit of an odd database where products are related via tags and are not hierarchical.
I'm trying to select a single product using a SKU number from a table and join it with a table of product reviews like so:
SELECT ims.master_sku, ims.title, ims.price,
ims.description, ir.mvp_number, ir.title,
ir.review, ir.rating, ir.created_on
FROM default_inventory_master_skus AS ims
JOIN default_inventory_reviews AS ir
WHERE ims.master_sku = '22284319'
GROUP BY ir.review;
This gives me around 150 rows - which are all the same product but contain different reviews. My question is how can I return just the one product (as a single row) and somehow convert the reviews into columns associated with that one product?
Again - thank you for your time and help.
Rich
You can do that, although it's not "relational".
Looks like someone wants this data in Excel ;).
With MySQL, you will need to generate an SQL statement and execute it. Either within MySQL (in a procedure) or outside (e.g., in PHP). Query first for the pivot column names, put together the statement, then execute it.
An idea of the implementation is here:
http://www.artfulsoftware.com/infotree/queries.php#78

Intersection table MySQL

i made three tables, two of them are just information about the customer and the product a third one is just holding the count of the products (more specific info)
two illustrate it! i put an imageSketch of tables and demanded output
Question 1: Is it a good idea doing it like i did?
Question 2: I'm working with PHP, so is it bad, when i try to populate arrays with subinformation, to build up my "demanded" table shown in the attached image?
Thank you very much