新人问个特简单的检索有关问题

新人问个特简单的检索问题
检索条件是控件值strValue
当用户输入了值的时候,这个strValue是确实有值的;但是有时候用户不一定会输入值,就直接按了检索按钮,这时候这个是空值了,那这个时候要把所有的记录都检索出来,这时候该怎么写sql语句呢?

select * from table where id = '"+ strValue +"'

我想要的是一条语句实现这两种可能性

------解决方案--------------------
在程序中根据strValue是否有值来动态产生查询的SQL语句
var sql:string
if strValue=='' then
sql="select * from table"
else
sql="select * from table where id='"+strValue+"'"
------解决方案--------------------
SQL code
select * from table where id = '"+ strValue +"' OR ID IS NULL

------解决方案--------------------
在程序中控制
C# code

string sql = 'select * from table where 1=1';
if (strValue=='')
sql=sql + " and id='"+strValue+"'"