Reputation: 77
Having trouble excluding data that is null, I just want to pull the rows that have discord_id
data. Here is the code I have:
<?php
$con=mysqli_connect("localhost","site","password","table");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM core_members");
while($row = mysqli_fetch_array($result))
{
echo $row['name'] . " " . $row['discord_id'];
echo "<br />";
}
mysqli_close($con);
?>
Upvotes: 2
Views: 176
Reputation: 130
Add the following where clause to your code:-
where discord_id is not null
Full Select Statement:
SELECT * FROM core_members where discord_id is not null;
Upvotes: 3
Reputation: 72299
You have to use MySQL: IS NOT NULL like below:-
$result = mysqli_query($con,"SELECT * FROM `core_members` WHERE `discord_id` IS NOT NULL");
Upvotes: 2
Reputation: 311393
Just add an is not null
condition:
$result =
mysqli_query($con, "SELECT * FROM core_members WHERE discord_id IS NOT NULL");
Upvotes: 1
Reputation: 69450
Add it as condition to the WHERE
clause:
SELECT * FROM core_members where discord_id is not null
Upvotes: 1