Jump to content

Mysql


Danny620

Recommended Posts

Hi i have a mysql query that produces 3 pet ids however i only have 1 in db whats going on?

 

SELECT pet.active, pet_id, activation_code, pet.user_id, pet_name, pet_type, status, DATE_FORMAT(pet.registration_date, '%M %d, %Y') AS rd FROM pet, users WHERE activation_code LIKE '%%' && pet_id LIKE '%%' && users.email LIKE '%%' ORDER BY pet.pet_id DESC LIMIT 700, 100

 

Edit 	Active 	Pet ID 	Activation Code 	User ID 	Pet Name 	Pet Type 	Status 	Registered Date 	Reset 	Delete
Edit 	Not In Use 	1017 	B0MQ0V19 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1017 	B0MQ0V19 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1016 	112X2FBG 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1016 	112X2FBG 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1016 	112X2FBG 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1015 	HJFW7DB9 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1015 	HJFW7DB9 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1015 	HJFW7DB9 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1014 	D9UCRRFC 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1014 	D9UCRRFC 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1014 	D9UCRRFC 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1013 	FPIZAVEB 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1013 	FPIZAVEB 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1013 	FPIZAVEB 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1012 	FVFAX4SF 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1012 	FVFAX4SF 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1012 	FVFAX4SF 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1011 	9XN6IKHL 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1011 	9XN6IKHL 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1011 	9XN6IKHL 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1010 	IOUTFI3X 	User ID 		Cat 	Safe At Home 		reset 	delete
Edit 	Not In Use 	1010 	IOUTFI3X 	User ID 		Cat 	Safe At Home 		reset 	delete

Link to comment
Share on other sites

You probably want a left join:

SELECT pet.active, pet_id, activation_code, pet.user_id, pet_name, pet_type, status, DATE_FORMAT(pet.registration_date, '%M %d, %Y') AS rd
FROM pet
LEFT JOIN users ON pet.user_id = users.user_id
WHERE activation_code LIKE '%%' && pet_id LIKE '%%' && users.email LIKE '%%' ORDER BY pet.pet_id DESC LIMIT 700, 100

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.