5 Replies - 403 Views - Last Post: 30 July 2018 - 10:48 AM

#1 Pogaca   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 142
  • Joined: 24-August 13

Complication with related database queries

Posted 30 July 2018 - 10:36 AM

Greetings,

So, I haave 3 tables in one databse of course. Database name is not important. This is the structure of tables:

Posted Image

I need to write only queries , it matters which language is used. But it has to be MySQL. So, 4 queries:

1. Write query which gives number of works from Spain (SPANIJA).
2. Write query which gives KUVARICE(SECTOR - KUVARICA) from Spain. (ŠPANIJA).
3. Write query which returns number of workers by state (DRZAVA). (DRZAVA_ID is special id for each country in second table)
4. Write query which returns state where total number of workers by state is larger than 2. (what they want to say is how many countries have total number of workers by state larger than 2). First column of first table is ID of worker. Second table first row is ID of state. Third table ID is worker ID with relationship with worker's ID from table one.

Is This A Good Question/Topic? 0
  • +

Replies To: Complication with related database queries

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15361
  • View blog
  • Posts: 61,607
  • Joined: 12-June 08

Re: Complication with related database queries

Posted 30 July 2018 - 10:38 AM

... ok, what have you tried, thought about, or considered?
Was This Post Helpful? 0
  • +
  • -

#3 Pogaca   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 142
  • Joined: 24-August 13

Re: Complication with related database queries

Posted 30 July 2018 - 10:41 AM

Well, it is easy for me to do this with access, because it is simple to make relationships etc. But when I use PHPMyadmin, well, it get's hard for me to do any relation. I forgot should I use join left, right, full. Long time ago I did all of this. I did first task, way before, much easier. But this is hard for me.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15361
  • View blog
  • Posts: 61,607
  • Joined: 12-June 08

Re: Complication with related database queries

Posted 30 July 2018 - 10:45 AM

Shouldn't be that hard to write it out.

If you need to bone up on your joins there are plenty of resources out there for that.

Ex:

Posted Image
Was This Post Helpful? 0
  • +
  • -

#5 Pogaca   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 142
  • Joined: 24-August 13

Re: Complication with related database queries

Posted 30 July 2018 - 10:47 AM

Yes- I checked it out. But simply couldn't write correct query.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15361
  • View blog
  • Posts: 61,607
  • Joined: 12-June 08

Re: Complication with related database queries

Posted 30 July 2018 - 10:48 AM

Mkay.. so you have three tables.. one being a table showing a relationship between the other two. Yes.. joins would be best.

If you are unclear which to use - perhaps just try a few out.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1