There are tons of usefull functions like that, so if you have more 'complex' queries, I suggest you take a few minutes to read the introduction pages of each of mySQL's manual sections. There may be 'smarter' ways of dealing with complex things. 🙂