By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE wp_posts (
ID BIGINT UNSIGNED,
post_title MEDIUMTEXT
);
INSERT INTO wp_posts(ID, post_title) VALUES (897, 'Lavender');
INSERT INTO wp_posts(ID, post_title) VALUES (899, 'Prince White Download');
INSERT INTO wp_posts(ID, post_title) VALUES (902, 'test');
INSERT INTO wp_posts(ID, post_title) VALUES (1019, 'تست');
INSERT INTO wp_posts(ID, post_title) VALUES (1034, 'kk');
INSERT INTO wp_posts(ID, post_title) VALUES (1035, 'کک');
create table wp_icl_translations
(
element_id bigint null,
trid bigint not null,
language_code varchar(7) not null,
source_language_code varchar(7) null
)
collate = utf8mb4_unicode_520_ci;
INSERT INTO wp_icl_translations (element_id, trid, language_code, source_language_code) VALUES (897, 897, 'en', null);
INSERT INTO wp_icl_translations (element_id, trid, language_code, source_language_code) VALUES (899, 899, 'en', null);
INSERT INTO wp_icl_translations (element_id, trid, language_code, source_language_code) VALUES (902, 902, 'en', null);
INSERT INTO wp_icl_translations (element_id, trid, language_code, source_language_code) VALUES (1019, 902, 'fa', 'en');
INSERT INTO wp_icl_translations (element_id, trid, language_code, source_language_code) VALUES (1034, 2844, 'en', null);
INSERT INTO wp_icl_translations (element_id, trid, language_code, source_language_code) VALUES (1035, 2844, 'fa', 'en');
select * from wp_posts;
select * from wp_icl_translations;
ID | post_title |
---|---|
897 | Lavender |
899 | Prince White Download |
902 | test |
1019 | تست |
1034 | kk |
1035 | کک |
element_id | trid | language_code | source_language_code |
---|---|---|---|
897 | 897 | en | null |
899 | 899 | en | null |
902 | 902 | en | null |
1019 | 902 | fa | en |
1034 | 2844 | en | null |
1035 | 2844 | fa | en |
select *
from (select w2.*
from wp_posts as w1
inner join wp_icl_translations as t1
on `ID` = `element_id` and t1.source_language_code IS NULL
#here
inner join wp_icl_translations as t2 on
#some condition to do the job?
t2.trid = t1.trid
#here
inner join wp_posts as w2
on w2.ID = t2.element_id) as `wp_posts`
ID | post_title |
---|---|
897 | Lavender |
899 | Prince White Download |
902 | test |
1019 | تست |
1034 | kk |
1035 | کک |