Codeigniter join multiple times same table and same column name - codeigniter

I'm having a problem, i have this table named IMOVEIS and another table named CARACTERISTICAS.
IMOVEIS must do at least 10 joins with CARACTERISTICAS, to get different caracteristics (this is a real state project).
Now I know how to make multiple joins in same table, the problem is: the column name of CARACTERISTICAS table (CT_NOME it's the column's name).
So how to change column name to each join result?

Related

joining tables with specialization-generalization relationship in oracle

I am trying to do a join with two tables. One is a supertype and one is a subtype. I am also trying to join it with another table and that works but the joining of the supertype and subtype is not. It says I have invalid identifier but he same id is in both so I am extremely confused why it's not working.
enter image description here
I included my code below and the attachment shows my tables. I have a table I am pulling first name and last name from and my other code is pulling from the supertype and subtype table.
SELECT first_name, last_name, gift_card_id, value_of_card
FROM gift_card
JOIN subject ON gift_card.subject_id = subject.subject_id
JOIN gift_card ON visa_gift_card.gift_card_id = gift_card.gift_card_id
GROUP BY gift_card.gift_Card_id
HAVING visa_gift_card.gift_card_id = gift_card.gift_card_id;
This is probably because you don't have first_name or last_name in any of your tables. Is there another table you should be joining on?
Also, I don't think group by/having is what you want, since you have no aggregate functions like sum in your select list.

How to select specific columns in a polymorphic relationship where table columns are different?

How can I only select specific columns in a polymorphic relationship because the table columns are different?
$query->with(['Postable' =>function($query){
$query->select('business_title','name ','last_name');
}
The business_title column exists in the agency table. Name and last_name exist in the user table. If I select one table other table gets an error of column not found.
Either develop a naming convention that fulfills your needs (ex: columns like 'name', 'title' can be found on many tables), or do not use select in your query and get all coulmns: $query->with(['Postable']); and you would need appropriate ways to read your query results. Or simply use multiple queries to read from different tables which seems to be the rational option.

How can I merge two tables using ROWID in oracle?

I know that ROWID is distinct for each row in different tables.But,I am seeing somewhere that two tables are being merged using rowid.So,I also tried to see it,but I am getting the blank output.
I have person table which looks as:
scrowid is the column which contains rowid as:
alter table ot.person
add scrowid VARCHAR2(200) PRIMARY KEY;
I populated this person table as:
insert into ot.person(id,name,age,scrowid)
select id,name, age,a.rowid from ot.per a;
After this I also created another table ot.temp_person by same steps.Both table has same table structure and datatypes.So, i wanted to see them using inner join and I tried them as:
select * from ot.person p inner join ot.temp_person tp ON p.scrowid=tp.scrowid
I got my output as empty table:
Is there is any possible way I can merge two tables using rowid? Or I have forgotten some steps?If there is any way to join these two tables using rowid then suggest me.
Define scrowid as datatype ROWID or UROWID then it may work.
However, in general the ROWID may change at any time unless you lock the record, so it would be a poor key to join your tables.
I think perhaps you misunderstood the merging of two tables via rowid, unless what you actually saw was a Union, Cross Join, or Full Outer Join. Any attempt to match rowid, requardless of you define it, doomed to fail. This results from it being an internal definition. Rowid in not just a data type it is an internal structure (That is an older version of description but Oracle doesn't link documentation versions.) Those fields are basically:
- The data object number of the object
- The data block in the datafile in which the row resides
- The position of the row in the data block (first row is 0)
- The datafile in which the row resides (first file is 1). The file
number is relative to the tablespace.
So while it's possible for different tables to have the same rowid, it would be exteremly unlikely. Thus making an inner join on them always return null.

ORACLE SQL Query to fetch all table names IN DB whereever given value is treated as PK

Just want to know is this possible.
Say that if i have value 'X' and iam sure that this is referenced in some other tables as PK value but not sure about exactly which table is that, so i would like to know the list of those tables.
Pseudo query of above what i mentioned
SELECT TABLE_NAME FROM DBA_TABLES WHERE <<ATLEAST ONE OF THE TABLE ROW PK VALUE IS MATCHING EQUAL TO 'X'>>;

How do I link two parse tables per common field?

I have a simple relationship between two parse tables (objects).
Both contain a 'name' string column.
All I need to do is to create a join between the two tables per 'name' column.
For example:
Table A (main) <--> Table B (ancillary)
where
'A.name' == 'B.name'.
Table A is the driving table: all criteria focuses on Table A.
Table B is the ancillary table that has a particular field (column) needed for Table A's result.
Note: the tables don't have any formal relation with each other.
What is the correct Parse syntax to allow this to happen?
...or must I make two queries instead on one merged query?

Resources