php/ mysql/ sql/ inner-join

I have this two columns:

在此输入图像描述

The first column name is TAGS and the second column name is PORTTAG.

I want to get all tags.nome that are not to be used on porttag.tag with porttag.port = 1

 $mysqli->query("SELECT nome FROM tags INNER JOIN porttag ON porttag.tag != tags.nome WHERE porttag.port = '".$_GET['edit']."'"); 

But without success!

Can you help me?

It seems as though you need to use the not exists operator:

SELECT nome 
FROM   tags t
WHERE  NOT EXISTS (SELECT * 
                   FROM   porttag p 
                   WHERE  p.tag = tags.nome AND p.port = 1)

I want to get all tags.nome that are not to be used on porttag.tag with porttag.port = 1

This makes me think of this:

select t.*
from tags t
where not exists (select 1 from porttag pt where pt.port = 1 and pt.tag = t.nome);

However, you have something very strange in your data model. The link between the tables should be based on the id not the name.

暂无
暂无

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question PHP MySQL inner join multiple values inner join mysql php INNER JOIN in mysql php inner join CSV values in string format to MySQL table in php Mysql PHP Search Inner Join PHP mysql multiple inner join PHP MySQL inner join issues PHP/MySQL - Rank on Inner Join PHP MySQL double inner join php mysql compare values
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM