rk thota wrote:select *
from RegisterComplaint R, ConsumerRegistration C
where R.CONSUMER-ID=C.CONSUMER-ID;
Don't use "SELECT *..." here because you will get two Consumer ID columns (the PK and the FK). Specify the individual columns you need instead.
In general,
you should be specific about which columns you need to fetch in your query, especially in a join query as here, so you know exactly which columns are being retrieved and in what order (e.g. for mapping into
Java), you don't get any nasty surprises if somebody changes the underlying table structure (e.g. to add a column that you are not handling in Java), and you don't waste resources fetching data that is never used.
Also, check your column names. If the Consumer ID column is really "CONSUMER-ID" (not CONSUMER_ID) then you will need to wrap it in double quotes i.e. SELECT "CONSUMER-ID" FROM..., or Oracle will think you're trying to subtract the value in a column called ID from the value in a column called CONSUMER.
It's better to avoid making column or table names case sensitive or using characters like "-" in names, as it just creates more scope for errors. If possible, use underscores in names e.g. CONSUMER_ID, not CONSUMER-ID, then you can simply write SELECT consumer_id FROM... and not worry about case-sensitivity or quotes.
Incidentally, the way you explained your requirement is basically the way you would write the SQL - "fetch X where ...", so why not just go ahead and
learn some SQL?