agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Karen Goh <karenworld@yahoo.com>
To: Avin Kavish <avinkavish@gmail.com>
Cc: Ron <ronljohnsonjr@gmail.com>
Cc: pgsql-admin@lists.postgresql.org
Subject: Re: How do I alter an existing column and add a foreign key which is a Primary key to a table?
Date: Sun, 21 Jul 2019 16:26:43 +0000 (UTC)
Message-ID: <842365220.2655538.1563726403478@mail.yahoo.com> (raw)
In-Reply-To: <CAFpscOTUNm2JZ1Vbv2h+BCnW5k7+ZJXWSBv_aP69Z7gRZo2Qhw@mail.gmail.com>
References: <820008379.2579287.1563670685484@mail.yahoo.com>
	<5CE41E80-274A-44DA-9553-E2DCA260F751@jakobs.com>
	<385857992.2643116.1563717238725@mail.yahoo.com>
	<923fb3b1-90e9-e0b5-bc5b-d896128c3f28@gmail.com>
	<1745586001.2633224.1563719075867@mail.yahoo.com>
	<CAKFQuwYwO4EdGQ_H6avBUQaeUTOyoLFw17OicCXsFzVVri4aUw@mail.gmail.com>
	<905425626.2686338.1563721213121@mail.yahoo.com>
	<CAKFQuwahWO9HrmcNjkfkaj0cAbFJB6mTVEOUGQZiy9EojTJQOw@mail.gmail.com>
	<2030754658.2646264.1563721831668@mail.yahoo.com>
	<75125c45-0fed-e5f1-50f0-9646db20dde6@gmail.com>
	<927283546.2681887.1563722628862@mail.yahoo.com>
	<CAFpscOTUNm2JZ1Vbv2h+BCnW5k7+ZJXWSBv_aP69Z7gRZo2Qhw@mail.gmail.com>




Sent from Yahoo Mail for iPhone


On Monday, July 22, 2019, 12:10 AM, Avin Kavish <avinkavish@gmail.com> wrote:

Hey Karen,

That query is pretty much an inner join with a filter that selects a single value from the matching rows. It's picking the tutor's zipcode from the tutor table where any tutor is teaching a subject called "Angela Merkel". For this to happen, it needs to join the tutor subjects with the tutor details table using the tutor id as the common factor.
Perhaps you should try www.stackoverflow.com for SQL guidance. They might be able to explain in detail what you are doing (wrong). Make sure to provide a complete example showing all the involved relations and references and any queries your wrote. This is reallyimportant or they downvote/close questions. (your original email is not sufficient detail)
This is the wrong forum so you need not reply cos Ron has mentioned already.
N also, why select zip code when it is not even supplied with a value?
If this is not the mailing list then why do PostgreSQL suggest user to subscribe this?


Regards,Avin
On Sun, Jul 21, 2019 at 8:54 PM Karen Goh <karenworld@yahoo.com> wrote:

 




On Sunday, July 21, 2019, 11:13:58 PM GMT+8, Ron <ronljohnsonjr@gmail.com> wrote:


On 7/21/19 10:10 AM, Karen Goh wrote:

>
> On Sunday, July 21, 2019, 11:06:16 PM GMT+8, David G. Johnston
> <david.g.johnston@gmail.com> wrote:
>
>
> On Sunday, July 21, 2019, Karen Goh <karenworld@yahoo.com> wrote:
>
>
> Is there a way for me to generate an entity table diagram vis pgAdmin4 or
> PSQL ?
>
>
> Just write the 5 or so tables out in a somewhat compressed format. Psql
> doesn’t and I don’t know about pgadmin
>
> Here is a compressed format :
>
> s_tutor
> --------
> zipcode(text)
> tutor_id (I just checked this is becomes a 'serial id ?' based on the
> generated sql
>
> ALTER TABLE public.s_tutor ALTER COLUMN tutor_id ADD GENERATED BY DEFAULT
> AS IDENTITY (
> SEQUENCE NAME public.tutor_strtutorid_seq
> START WITH 1
> INCREMENT BY 1
> NO MINVALUE
> NO MAXVALUE
> CACHE 1
> );
>
> tutor_subject
> ----------------
> tutor_id
> subject_Names


select s_tutor.zipcode
from s_tutor, tutor_subject
where s_tutor.tutor_id = tutor_subject.tutor_id
 and tutor_subject.subject_names ='Angela Merkel'

Hi Ron,

Could you explain why you select s_tutor.zipcode from tutor_subject since there is no zipcode inside tutor_subject?

Perhaps my reasoning is wrong and I really want to have your expert view. 


-- 
Angular momentum makes the world go 'round.



  

view thread (26+ messages)  latest in thread

Message-ID: <842365220.2655538.1563726403478@mail.yahoo.com>
Permalink:  ../842365220.2655538.1563726403478@mail.yahoo.com/
Also on:    postgresql.org/message-id/842365220.2655538.1563726403478@mail.yahoo.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: karenworld@yahoo.com, avinkavish@gmail.com, ronljohnsonjr@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: How do I alter an existing column and add a foreign key which is a Primary key to a table?
  In-Reply-To: <842365220.2655538.1563726403478@mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox