0 Replies - 282 Views - Last Post: 13 October 2017 - 09:34 PM Rate Topic: -----

#1 Joshieboy2007  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 135
  • Joined: 26-March 14

PLSQL Question

Posted 13 October 2017 - 09:34 PM

I have a few tables that are related and i'm bascially trying to find out if a table has more than one instance of the foreign key and than i will update the other table if it does.

Soo as a more visual diagram.

I have a Trans(TD ,Sal) Store(NAME, TD)

So I want to basically loop through and if more than 4 books has the same instance of the same TD than will increase sal by 1.

I've thought about

select count(*)into test
from Trans
where TD in (select TD from Store);



where test is a number, but wouldn't that only just tell if there is some TD is greater than 4?

Than i thought of

IF(
select count(*)
from Trans
where TD in (select TD from Store) >= 3
)
THEN
..
END IF;



But that doesn't seem to work either. Any help would be appreciated.

This post has been edited by Joshieboy2007: 13 October 2017 - 09:35 PM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1