Admin do you have MongoDB group too?

|
drfibonacci 2020-08-15 09:57:52
Someone please help me out 🙁
drfibonacci 2020-08-15 10:54:00
So I found a solution like this:

WITH total as (SELECT SUM(Amount) as total FROM “table”)
SELECT Amount *100/total.total AS Percent FROM “table”,total;

Is there a better solution?

Professor_Mi 2020-08-15 11:58:15
mysql_en-5113.jpg

Professor_Mi 2020-08-15 11:58:16
mysql_en-5115.jpg

Professor_Mi 2020-08-15 11:58:16
mysql_en-5114.jpg

Professor_Mi 2020-08-15 11:59:02
Hello everybody needs some help in fetching comma-separated data by combining Two tables resume and vacancy. wants to show results by matching same work location and same job_category and interest.
Professor_Mi 2020-08-15 11:59:04
SELECT vacancy.job_category, vacancy.job_location, resume.interest, resume.work_location FROM vacancy, resume
WHERE vacancy.job_category LIKE ‘%resume.interest%’
Professor_Mi 2020-08-15 11:59:25
this is the query I used but no result is showing need help to build the query
drfibonacci 2020-08-15 12:07:07
Professor_Mi 2020-08-15 11:59:25
this is the query I used but no result is showing need help to build the query

So interest IN job_category and job_location IN work_location?

drfibonacci 2020-08-15 12:07:50
Is that what you want?
Professor_Mi 2020-08-15 12:08:10
drfibonacci 2020-08-15 12:07:50
Is that what you want?

Let me try once

drfibonacci 2020-08-15 12:08:19
IN won’t work
drfibonacci 2020-08-15 12:08:31
As its not a column – values are separated by comma
Professor_Mi 2020-08-15 12:08:49
Ya that is the problem I want to fix
Professor_Mi 2020-08-15 12:09:00
Single data is getting fetched
drfibonacci 2020-08-15 12:09:05
However, you can extract the individual values using SUBSTR in a subquery and then compare data
Professor_Mi 2020-08-15 12:09:13
But not with , separated
Professor_Mi 2020-08-15 12:09:58
drfibonacci 2020-08-15 12:09:05
However, you can extract the individual values using SUBSTR in a subquery and then compare data

Hmm, let me try..

drfibonacci 2020-08-15 13:39:14
I was mistaken
drfibonacci 2020-08-15 13:39:48
Regexp cannot be used since sql doesn’t allow values from another column to be matched in its regex expression
drfibonacci 2020-08-15 13:40:15
The FIND_IN_SET() fx has to be used – I think I know how to do this
drfibonacci 2020-08-15 13:40:31
Will post the solution in 3 – 4 hours
Professor_Mi 2020-08-15 13:47:15
drfibonacci 2020-08-15 13:39:48
Regexp cannot be used since sql doesn’t allow values from another column to be matched in its regex expression

Yaa that I tried yesterday but didn’t help therefore switch to other methods

MasterZiv 2020-08-15 14:30:53
drfibonacci 2020-08-15 10:54:00
So I found a solution like this:

WITH total as (SELECT SUM(Amount) as total FROM “table”)
SELECT Amount *100/total.total AS Percent FROM “table”,total;

Is there a better solution?

This one is quite good, but ISIN a derived table introduced with WITH keyword is not necessary here, you could just have it like a simple uncorrelated subquery.

MasterZiv 2020-08-15 15:17:01
Professor_Mi 2020-08-15 11:59:04
SELECT vacancy.job_category, vacancy.job_location, resume.interest, resume.work_location FROM vacancy, resume
WHERE vacancy.job_category LIKE ‘%resume.interest%’

Emmm….
It seems you have join condition missing in your quiery. You have two tables, so there must be some join condition in it.

Also, never use non-ANSI join syntax, use JOIN explicitly.

drfibonacci 2020-08-15 15:36:50
@Neche_se_topper

Here’s your query:

SELECT `resume`.`Person_ID`, `vacancy`.* FROM `vacancy`
INNER JOIN `resume` ON
(FIND_IN_SET(REPLACE(`vacancy`.`job_location`,’ ‘,”), REPLACE(`resume`.`work_location`,’ ‘,”)) > 0 AND
FIND_IN_SET(REPLACE(`vacancy`.`job_category`,’ ‘,”), REPLACE(`resume`.`interest`,’ ‘,”)) > 0);

drfibonacci 2020-08-15 15:37:59
mysql_en-5140.jpg
resume table
drfibonacci 2020-08-15 15:38:23
mysql_en-5143.jpg
vacancy table
drfibonacci 2020-08-15 15:38:54
mysql_en-5144.jpg
Query result
drfibonacci 2020-08-15 15:41:07
drfibonacci 2020-08-15 15:36:50
@Neche_se_topper

Here’s your query:

SELECT `resume`.`Person_ID`, `vacancy`.* FROM `vacancy`
INNER JOIN `resume` ON
(FIND_IN_SET(REPLACE(`vacancy`.`job_location`,’ ‘,”), REPLACE(`resume`.`work_location`,’ ‘,”)) > 0 AND
FIND_IN_SET(REPLACE(`vacancy`.`job_category`,’ ‘,”), REPLACE(`resume`.`interest`,’ ‘,”)) > 0);

If you want, you can add a LOWER() fx to REPLACE()

drfibonacci 2020-08-15 15:41:29
But FIND_IN_SET() fx is case-insensitive
MasterZiv 2020-08-15 15:54:48
drfibonacci 2020-08-15 15:36:50
@Neche_se_topper

Here’s your query:

SELECT `resume`.`Person_ID`, `vacancy`.* FROM `vacancy`
INNER JOIN `resume` ON
(FIND_IN_SET(REPLACE(`vacancy`.`job_location`,’ ‘,”), REPLACE(`resume`.`work_location`,’ ‘,”)) > 0 AND
FIND_IN_SET(REPLACE(`vacancy`.`job_category`,’ ‘,”), REPLACE(`resume`.`interest`,’ ‘,”)) > 0);

Such join will not work in production, it is O(N * M), N,M – sizes of the tables.

drfibonacci 2020-08-15 15:59:54
MasterZiv 2020-08-15 15:54:48
Such join will not work in production, it is O(N * M), N,M – sizes of the tables.

I know 🙁

But I couldn’t find a faster way; I mean, a join has to happen but optimizing this query is out of scope for me xD

drfibonacci 2020-08-15 16:00:29
Either way, at least the query will produce results now
MasterZiv 2020-08-15 16:15:33
drfibonacci 2020-08-15 15:59:54
I know 🙁

But I couldn’t find a faster way; I mean, a join has to happen but optimizing this query is out of scope for me xD

You must redesign the DB

Master Yoda 2020-08-15 16:16:09
drfibonacci 2020-08-15 10:54:00
So I found a solution like this:

WITH total as (SELECT SUM(Amount) as total FROM “table”)
SELECT Amount *100/total.total AS Percent FROM “table”,total;

Is there a better solution?

Not necessarily a better solution this is. But temporary tables are useful too

drfibonacci 2020-08-15 16:17:21
MasterZiv 2020-08-15 16:15:33
You must redesign the DB

Well, I did suggest it yesterday – but maybe its for a project so he didn’t heed my advice

Master Yoda 2020-08-15 16:17:35
MasterZiv 2020-08-15 14:30:53
This one is quite good, but ISIN a derived table introduced with WITH keyword is not necessary here, you could just have it like a simple uncorrelated subquery.

Yes, WITH is only available since MYSQL 8. It could have been done with normal query too

drfibonacci 2020-08-15 16:17:41
drfibonacci 2020-08-15 16:17:21
Well, I did suggest it yesterday – but maybe its for a project so he didn’t heed my advice

I think storing the data as json would be better

drfibonacci 2020-08-15 16:19:02
Master Yoda 2020-08-15 16:16:09
Not necessarily a better solution this is. But temporary tables are useful too

Go easy on me, I’m just learning SQL

drfibonacci 2020-08-15 16:19:11
I’m a MongoDB gal xD
Master Yoda 2020-08-15 16:19:35
drfibonacci 2020-08-15 16:19:02
Go easy on me, I’m just learning SQL

Just saying ))

Master Yoda 2020-08-15 16:20:56
drfibonacci 2020-08-15 16:19:11
I’m a MongoDB gal xD

Well, then you can teach me a lot about MongoDB too. Trying to do self study and was hoping to experiment with replication from MYSQL to Mongo. As lazy I am I never could. 😁

Master Yoda 2020-08-15 16:22:09
MasterZiv 2020-08-15 15:17:01
Emmm….
It seems you have join condition missing in your quiery. You have two tables, so there must be some join condition in it.

Also, never use non-ANSI join syntax, use JOIN explicitly.

Admin do you have MongoDB group too?

drfibonacci 2020-08-15 16:22:40
Master Yoda 2020-08-15 16:20:56
Well, then you can teach me a lot about MongoDB too. Trying to do self study and was hoping to experiment with replication from MYSQL to Mongo. As lazy I am I never could. 😁

Mongo is a lot more flexible – but the more I learn about RDBMS, the more I get impressed

Master Yoda 2020-08-15 16:24:19
drfibonacci 2020-08-15 16:22:40
Mongo is a lot more flexible – but the more I learn about RDBMS, the more I get impressed

Well at least I assume you have such setup in your organization so you learn new things. I am stuck with MYSQL and MariaDB as they only use this. And once I was out of University I had little motivation to read. Although I read lot about other things not tech.

drfibonacci 2020-08-15 16:27:35
Mongo gets a pretty bad rep in the industry because of its ‘non-ACID compliance’ when its mostly untrue
drfibonacci 2020-08-15 16:28:36
Mongo’s advantage lies in its flexible schema design – so updation of one document is inherently ACID compliant
drfibonacci 2020-08-15 16:31:40
But Mongo now supports multi doc transactions, which comes as a performance tradeoff.

Hardcore companies will not move away from RDBMS since there’s been a lot of research in it and it would seem as a sort of an unnecessary risk(now that DBs support JSON, why would they need to even..)

drfibonacci 2020-08-15 16:32:44
As for me – I will prefer RDBMS for structured data anyday
|