# \[MYSQL\] exclude some results

**URL:** <https://forum.kirupa.com/t/mysql-exclude-some-results/157637>\
**Category:** programming\
**Created:** [August 3, 2005, 10:53am UTC](https://forum.kirupa.com/t/mysql-exclude-some-results/157637 "2005-08-03T10:53:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![will\_roberts](https://avatars.discourse-cdn.com/v4/letter/w/4da419/32.png) [@will\_roberts](https://forum.kirupa.com/u/will_roberts)\
**Post date:** [August 3, 2005, 10:53am UTC](https://forum.kirupa.com/t/mysql-exclude-some-results/157637/1 "2005-08-03T10:53:24Z")

</div>

Hey all,

i am trying to find a way to exclude certain results from my query.  
here is what i have so far

```auto

<?
$username = "xxxx"; 
$password = "xxxx"; 
$host = "xxxx"; 
$database = "xxxx"; 
$table = "xxxx"; 

mysql_connect($host,$username,$password) or die("Cannot connect to the database.<br>" . mysql_error()); 

mysql_select_db($database) or die("Cannot select the database.<br>" . mysql_error()); 

if(!isset($page)) { 
$page = 0; // leave this as is 
} 
$limit = 1; // defines how many entries per page 
$sql = "SELECT * FROM $table ORDER BY RAND() DESC LIMIT $page,$limit"; 
$query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error()); 
while($result = mysql_fetch_array($query)) { 
$Field = $result["Image"]; // extract all your fields here like normal 
$Field2 = $result["Url"]; // extract all your fields here like normal 
$Field3 = $result["Alt"]; // extract all your fields here like normal 

echo "<a href=\"$Field2\"><img src=\"$Field\" alt=\"$Field3\" width=\"315\" height=\"304\" class=\"picborder\" /></a>";
} 

?>

```

now some of the results have 0 as the url and these are the ones i want to remove from the results so basically all the ones with a full url will show but not the ones with 0

Thanks in advance peeps.  
I know i am missing a simple trick here which makes me kinda angry 😛
