cmd.CommandText = @"SELECT * FROM tableA, tableB WHERE tableA.someid = tableB.someid AND UPPER(name) LIKE @name LIMIT 1"; cmd.Parameters.AddWithValue("@name", _name.ToUpper() + "%");
是否可以从名称匹配的 tableA 中进行选择,即使 tableA.someid = tableB.someid 条件失败?当前,如果 tableB 没有匹配的 someid,但有匹配的名称,则此查询不返回任何数据。
if tableA.someid = tableB.someid && UPPER(name) LIKE @name
return all data from both tables
if tableA.someid != tableB.someid
return all from tableA where UPPER(name) LIKE @name