Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Some MySQL Question

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch

xrvel

i love automationVIP Member
Impact
165
Hi,

How to make MySQL function that returns list of data.
Here is the mockup that i want

Code:
function get_users() {
	@data = SELECT * FROM users;
	RETURN @data;
}

Plus how do i assign value of a column into MySQL variable.
Here is the mockup of what i want.
Code:
SELECT
	users.name,
	@var_a = (
		SELECT COUNT(*) FROM pets WHERE pets.owner_id = users.user_id
	) AS pet_count
FROM
	users
WHERE
	@var_a > 10

I know the codes above are totally wrong in syntax :p
Thanks for helping. :D
 
Last edited:
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Wait.. you want this as a MySQL function? Or are you wanting this done in PHP? It's late here, just want to make sure I understand :gl:
 
0
Close
Wait.. you want this as a MySQL function? Or are you wanting this done in PHP? It's late here, just want to make sure I understand :gl:
I want it to be done on MySQL function, or probably stored procedure (which is best or more suitable in this case on your opinion) :)
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back