我正在尝试使用 sql 和 asp.net 执行搜索功能。我创建了一个 Gridview,它使用以下 sqldatasource sql 语句来检索数据。
SELECT customer.fisrtname,
customer.lastname,
customer.initials,
customer.title,
address.street,
area.area,
suburb.suburbname
FROM address
INNER JOIN area
ON address.areaid = area.areaid
INNER JOIN areasuburb
ON area.areaid = areasuburb.areaid
INNER JOIN customeraddress
ON address.addressid = customeraddress.addressid
INNER JOIN customer
ON customeraddress.customerid = customer.customerid
INNER JOIN suburb
ON areasuburb.suburbid = suburb.suburbid
WHERE ( customer.lastname LIKE '%' + @Lastname + '%' )
OR ( address.street LIKE '%' + @Street + '%' )
我遇到的问题是,如果用户没有在姓氏字段中输入任何值,那么即使有有效数据,该语句也不会返回任何数据。
请对此提供任何帮助,我们将不胜感激。