$tb=$_POST['tb'];
$strSQL="select name from syscolumns where id = (select id from sysobjects where type = 'U' and [name]='$tb')";
เป็นการ select ฟิลด์ ของ ตารางนั้นมาหมดเลย
ที่ผมเข้าใจ คือเอา Columns ที่อยู่ใน A แต่ไม่อยู่ใน B ใช้หรือป่าวไม่แน่ใจนะ
select a.name
from syscolumns a
inner join (select name from syscolumns where id (select id from sysobjects where type = 'U' and [name] = 'tb2')) b
on a.name <> b.name
where a.id = (select id from sysobjects where type = 'U' and [name]='$tb')
$strSQL="select distinct(a.name) from syscolumns a
inner join WEB_TBFIELD b
on a.name = b.FIELD_NAME
where a.id = (select id from sysobjects where type = 'U' and [name]='$tb')";
$strSQL="select a.name from syscolumns a
inner join WEB_TBFIELD b
on a.name <> b.FIELD_NAME
where a.id = (select id from sysobjects where type = 'U' and [name]='$tb')";
$strSQL="select distinct(a.name) from syscolumns a
inner join WEB_TBFIELD b
on a.name <> b.FIELD_NAME
where a.id = (select id from sysobjects where type = 'U' and [name]='$tb')";
select distinct(cc.name) from
(select distinct(c.name) from syscolumns c
where c.id = (select id from sysobjects where type = 'U' and [name]='web_permit')) cc
//ข้างบนออก 4 ฟิล
right outer join
(select distinct(a.name) from syscolumns a //ออก2 ฟิลที่ซ้ำกับข้างบน
inner join (select FIELD_NAME from WEB_TBFIELD) b
on a.name = b.FIELD_NAME
where a.id = (select id from sysobjects where type = 'U' and [name]='web_permit')) dd
on cc.name = dd.name