2

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);?>
Mureinik's user avatar
Mureinik
316k54 gold badges400 silver badges405 bronze badges
askedAug 28, 2017 at 8:44
Zen's user avatar
2

4 Answers4

3

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's user avatar
Death-is-the-real-truth
72.3k10 gold badges59 silver badges105 bronze badges
answeredAug 28, 2017 at 8:47
Fabian Steiner's user avatar
Sign up to request clarification or add additional context in comments.

Comments

2

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's user avatar

1 Comment

@Zen GLAD TO HELP YOU :):)
1

Add it as condition to theWHERE clause:

SELECT * FROM core_members where discord_id is not null
answeredAug 28, 2017 at 8:45
Jens's user avatar

Comments

1

Just add anis not null condition:

$result =     mysqli_query($con, "SELECT * FROM core_members WHERE discord_id IS NOT NULL");
answeredAug 28, 2017 at 8:46
Mureinik's user avatar

Comments

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.