Salis Posted March 26, 2007 Share Posted March 26, 2007 (SELECT * FROM blogs WHERE username='$username' ORDER BY pid DESC LIMIT $limit) OK, This works. My buddy and I own a web site. We both have bolgs and as a most servers have it we are limited to how many databases we can have. I created a database that contains the content of our site and I have also created a table labeled blogs. OK this table holds the blogs for both of us and is working very nice. Well I when I structured the database I added a row labeled Deleted with a default value 'false'. The idea is simple, if that value is true then the corresponding entry will not be displayed. if( $us_row['Deleted'] == 'false'] ) { echo $us_row['Entry']; } This also works. But my problem is that this effects the number of entries displayed. I would like a constant number of blog entries to be displayed, say 10, but if one is 'Deleted' then only 9 are shown. My question is, is there something I can add to the query exclude the entries with a true valued? Does this make since? Link to comment https://forums.phpfreaks.com/topic/44363-solved-query-help-needed/ Share on other sites More sharing options...
Salis Posted March 27, 2007 Author Share Posted March 27, 2007 Well after a long search online I found what I was looking for: (SELECT * FROM blogs WHERE (username='$username') AND deleted NOT IN ('true') ORDER BY pid DESC LIMIT $limit); Which "AND deleted NOT IN ('true')" is a little confusing... ("and where true is not in deleted"...) Link to comment https://forums.phpfreaks.com/topic/44363-solved-query-help-needed/#findComment-215866 Share on other sites More sharing options...
Wildbug Posted May 30, 2007 Share Posted May 30, 2007 Usually IN() is most useful with more than one value, such as a list of values. It's more standard, easier to read, and possibly faster, to use something like: SELECT * FROM blogs WHERE username='$username' AND deleted != 'true' ORDER BY pid DESC LIMIT $limit // or SELECT * FROM blogs WHERE username='$username' AND deleted ='false' ORDER BY pid DESC LIMIT $limit Link to comment https://forums.phpfreaks.com/topic/44363-solved-query-help-needed/#findComment-265043 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.