RSS Forums RSS
Please support our MySQL advertiser: Programming Forums

select statemt LIKE

Join Date: Jul 2005
Posts: 41
Reputation: ohgosh is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ohgosh's Avatar
ohgosh ohgosh is offline Offline
Light Poster

select statemt LIKE

  #1  
Jul 27th, 2005
i wud like to select records which userStatus' values is sth.

ive gt a tbl with a userStatus column, dis column is stored with statusID and the values in dis column, userStatus, are either numbers or nothing inside.

now i wud like to retrieve the userStatus which values are sth inside and hw shd i retrieve? cos in d web form ive gt a listbox showing all the status. now im including an ALL status to select all the status frm the db.

<%sql = "Select * from status ORDER BY statusType ASC"
set rsS = Conn.Execute(sql)

do while not rsS.eof
response.Write("<option value='"&rsS("statusID")&"'")
if request.QueryString("statusType") <> "" then
state = split(request.QueryString("statusType"),"|")
for each rec in state
if rsS("statusID") = Cint("0" & rec) then response.Write(" selected")
next
end if
response.Write(">"&rsS("statusType")&"</option>")
rsS.moveNext
loop
%>
</select>


if request.QueryString("statusType") <> "" then
sqlC = "select * from t_user_account where (userStatus='"&replace(request.QueryString("statusType"),"|","' or userStatus = '")&"')"

set rsC= conn.execute(sqlC)
end if


btw do anyone noe hw to explain such select sql statemt:
select * from user_acc where userStatus like '%_%'

to my knowledge, i understand that userStatus like '%%' is to retrieve evry single rec frm d tbl.

and _ is to select a single char but it shd b coded with like this: '_' then the userStatus = 5, 6 will be retrieved.

so hw abt userStatus like '%_%'?

thanks in advance!!
AddThis Social Bookmark Button
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 12:14 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC