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

Some MySQL Question

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
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
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back