I am working on PHP with mysql, Right now i have following two tables,And i want to display minimum value according to collection id,Here is my first table "nft_info"
id collection_id name
1 18 abc
2 18 xyz
3 19 hax
...
And here is my table "nft_sell_info"
id nft_id listing_price
1 1 15
2 2 50
3 3 30
...
Now i want to get minimum value of "listing_price" regarding collection_id=’18’, I tried with following query but giving me wrong result (showing 50 instead of 15 )
SELECT MIN(ns.listing_price) AS lowest_price
FROM `nft_info` `ni`
JOIN `nft_sell_info` `ns`
ON `ns`.`nft_id` = `ni`.`id`
WHERE `ni`.`collection_id` = '1'
3
Answers
You need to use the AS aliasing throughout your code because the abbreviation isn’t working without AS.
You are query is working fine if you change the
ni
.collection_id
= ‘1’to
Here is the code I used to test: