Can I do this in one query or do I have to do the checking in another language?

|
notpeepeepoopoo 2019-12-30 12:46:53
notpeepeepoopoo 2019-12-30 12:46:45

Well this seems to work… Correct me if im wrong

piterden 2019-12-30 12:47:58
What do you want to join if you are selecting count?
notpeepeepoopoo 2019-12-30 12:48:41
Genreid
piterden 2019-12-30 12:49:07
To count of tracks?
notpeepeepoopoo 2019-12-30 12:49:21
piterden 2019-12-30 12:49:07
To count of tracks?

Yes, tracks with a given genre

piterden 2019-12-30 12:50:21
You dont need join, you have genreid
notpeepeepoopoo 2019-12-30 12:50:42
There is genreid and music name in one table
notpeepeepoopoo 2019-12-30 12:50:53
There is genreid and genre name in other table
piterden 2019-12-30 12:51:03
Try to make a reversed selection
notpeepeepoopoo 2019-12-30 12:51:14
I want to count the number of songs with genre name …
piterden 2019-12-30 12:51:20
From genre to track
notpeepeepoopoo 2019-12-30 12:51:43
piterden 2019-12-30 12:51:03
Try to make a reversed selection

I have no idea about this 😐

piterden 2019-12-30 12:52:03
And also read about joins. You have incorrect one
notpeepeepoopoo 2019-12-30 12:52:18
Is there a need to joinM
piterden 2019-12-30 12:53:05
I told what do you need to do
piterden 2019-12-30 12:55:13
Read about joins and check out some examples
MasterZiv 2019-12-30 12:58:13
notpeepeepoopoo 2019-12-30 12:36:23
I cant understand how to link the two tables 😔

It’s very simple query.
Read Martin Gruber’s book for this.

MasterZiv 2019-12-30 12:58:58
notpeepeepoopoo 2019-12-30 12:39:21
Should i perform a natural join?

Here even a join is not strictly necessary, though, you can do this with a join

MasterZiv 2019-12-30 12:59:32
notpeepeepoopoo 2019-12-30 12:46:53
Well this seems to work… Correct me if im wrong

no this is incorrect.

notpeepeepoopoo 2019-12-30 13:00:19
MasterZiv 2019-12-30 12:59:32
no this is incorrect.

Yeah, i forgot the join condition

MasterZiv 2019-12-30 13:00:22
piterden 2019-12-30 12:50:21
You dont need join, you have genreid

He must select the genre by its name, first.

notpeepeepoopoo 2019-12-30 13:00:25
Now it is working fine
MasterZiv 2019-12-30 13:00:28
notpeepeepoopoo 2019-12-30 13:00:19
Yeah, i forgot the join condition

+

notpeepeepoopoo 2019-12-30 13:01:10
mysql_en-1202.jpg

notpeepeepoopoo 2019-12-30 13:01:52
mysql_en-1203.jpg
The schema is this
notpeepeepoopoo 2019-12-30 13:02:10
How to connect these tables
MasterZiv 2019-12-30 13:02:12
notpeepeepoopoo 2019-12-30 13:01:10

read books, don’t study by ‘try and fail’ method.

notpeepeepoopoo 2019-12-30 13:02:38
MasterZiv 2019-12-30 13:02:12
read books, don’t study by ‘try and fail’ method.

I will santa

MasterZiv 2019-12-30 13:02:57
notpeepeepoopoo 2019-12-30 13:02:38
I will santa

I’m not Santa

MasterZiv 2019-12-30 13:03:15
It’s umpaloomp
TheQuotidian 2019-12-30 13:55:51
notpeepeepoopoo 2019-12-30 13:01:52
The schema is this

You need an Order Dimension between these two dimensions to do anything meaningful with these two many to many relationship dimensions.

TheQuotidian 2019-12-30 13:56:30
Employee – > Order <- Customer
TheQuotidian 2019-12-30 14:02:53
piterden 2019-12-30 12:36:52
So if the table is round, can I split it to sectors?

Yes. Partitioning is useful in dealing with rotating data. If MySQL can easily identify rows to delete and map them to single partition, instead of running DELETE FROM table WHERE. One can truncate the partition if Range partitioned.

TheQuotidian 2019-12-30 14:04:32
MasterZiv 2019-12-30 13:02:57
I’m not Santa

Decide what the model would be used for then Design on paper, redo if required, then touch mysql

sixpeteunder 2019-12-30 16:02:16
Hi. I have a MySQL question. I have two tables, A and B. A’s primary key is a foreign key in B. How would I go about setting the value of A.description as the default for B.description?
MasterZiv 2019-12-30 16:06:56
sixpeteunder 2019-12-30 16:02:16
Hi. I have a MySQL question. I have two tables, A and B. A’s primary key is a foreign key in B. How would I go about setting the value of A.description as the default for B.description?

Table field’s defaults must be only simple constant values or simple expressions based on constants and functions, you cannot reference other tables in a DEFAULT constraint .

For this, you have to use triggers.

But I would not do this at all, you can just substitute value of B.description with value of A.description if B.description is empty, in all selecting queries.

sixpeteunder 2019-12-30 16:10:21
Thank you, I did not think of this. I did not want to populate the field with triggers because I would also have to handle updates to A.description.
sixpeteunder 2019-12-30 16:16:39
This implies that, in my queries, I should check if B.description is empty, and if so, fetch A.description in its place. Correct?
sixpeteunder 2019-12-30 16:18:53
sixpeteunder 2019-12-30 16:16:39
This implies that, in my queries, I should check if B.description is empty, and if so, fetch A.description in its place. Correct?

Follow up question, if so. Can I do this in one query or do I have to do the checking in another language?

MasterZiv 2019-12-30 16:39:01
sixpeteunder 2019-12-30 16:16:39
This implies that, in my queries, I should check if B.description is empty, and if so, fetch A.description in its place. Correct?

Yes. this can be done with simple CASE expression or COALESCE() function.

MasterZiv 2019-12-30 16:39:40
sixpeteunder 2019-12-30 16:18:53
Follow up question, if so. Can I do this in one query or do I have to do the checking in another language?

This can and (I think) must be done in a simple query

sixpeteunder 2019-12-30 16:48:00
MasterZiv 2019-12-30 16:39:40
This can and (I think) must be done in a simple query

Pardon my ignorance, but how would such a query look?

sixpeteunder 2019-12-30 16:54:10
mysql_en-1234.jpg
Something like this?
MasterZiv 2019-12-30 17:04:06
sixpeteunder 2019-12-30 16:48:00
Pardon my ignorance, but how would such a query look?

SELECT …
COALESCE( B.description, A.description ) as description
from A join B on …

MasterZiv 2019-12-30 17:05:28
sixpeteunder 2019-12-30 16:54:10
Something like this?

this is not correct, must be B left join A, but B seems to be dependent , child entity, can’t exist without A, so this is INNER JOIN

Ganesh 2019-12-30 17:13:28
Hi All
We are getting access denied for user on log(mysql-critter.err) in mysql database.

What could be the issue?
Where to check the issue and how to resolve the issue?

MasterZiv 2019-12-30 17:18:14
Ganesh 2019-12-30 17:13:28
Hi All
We are getting access denied for user on log(mysql-critter.err) in mysql database.

What could be the issue?
Where to check the issue and how to resolve the issue?

users in MySQL depend also on the host, from which you connect to the DB. So if you use a login Mrfoo and you connect from one host , this is one user, and if you use same login, but connect from another host — this is another user.

So check this first of all

notpeepeepoopoo 2019-12-30 17:34:43
Can someone recommend me books which will cover from basics to advanced in SQL?
MasterZiv 2019-12-30 17:35:24
notpeepeepoopoo 2019-12-30 17:34:43
Can someone recommend me books which will cover from basics to advanced in SQL?

Martin Gruber

notpeepeepoopoo 2019-12-30 17:36:03
MasterZiv 2019-12-30 17:35:24
Martin Gruber

Free understanding MySQL?

|