Having trouble excluding data that is null, I just want to pull the rows that havediscord_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);?>- Possible duplicate ofMySQL SELECT only not null valuesMasivuye Cokile– Masivuye Cokile2017-08-28 08:47:26 +00:00CommentedAug 28, 2017 at 8:47
- 1Would you like to do it on the PHP or mysql side?jhoepken– jhoepken2017-08-28 08:49:23 +00:00CommentedAug 28, 2017 at 8:49
4 Answers4
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;Death-is-the-real-truth
72.3k10 gold badges59 silver badges105 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
You have to useMySQL: IS NOT NULL like below:-
$result = mysqli_query($con,"SELECT * FROM `core_members` WHERE `discord_id` IS NOT NULL"); answeredAug 28, 2017 at 8:46
Death-is-the-real-truth
72.3k10 gold badges59 silver badges105 bronze badges
1 Comment
Death-is-the-real-truth
@Zen GLAD TO HELP YOU :):)
Add it as condition to theWHERE clause:
SELECT * FROM core_members where discord_id is not nullComments
Just add anis not null condition:
$result = mysqli_query($con, "SELECT * FROM core_members WHERE discord_id IS NOT NULL");Comments
Explore related questions
See similar questions with these tags.

