示例:
我有以下select连接多个表的查询,
SELECT
col1.id OBJECTID,
def.name TYPE,
pm.partn NODENUMBER,
pm.name NODENAME,
org.name ORGNAME,
string.value CONTEXT
FROM
PART col1, PARTMASTER pm, TYPEDEFINITION def, ORGA org,
STRINGVALUE string, STRINGDEFINITION def2, partmaster pmpf, part ppf
因此选择了多个记录,我需要得到那些记录。我怎么才能得到它 ?
答案 0 :(得分:0)
是你的数据库mysql?试试这个:
SELECT count(1), col1.id OBJECTID, def.name TYPE, pm.partn NODENUMBER, pm.name NODENAME, org.name ORGNAME, string.value CONTEXT FROM PART col1, PARTMASTER pm, TYPEDEFINITION def, ORGA org, STRINGVALUE string, STRINGDEFINITION def2, partmaster pmpf, part ppf
只需在您的sql语句中添加count(1)
。