Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Sorry for grammar mistakes. I want to create a currency table for my project which will use for adding currencies of different countries. This is my currency table but I'm confuse that this will good or not for project, so should I delete or add more columns in this table? Please help me.
currency
id | symbol | description | country | date_added | date_updated
I believe you better should have two tables.
One table for currency descriptions with fields id, symbol, description, country and other table related to this for daily currency rates with fields currency_id, rate, time_updated.
The question is if you really need the date_added. I think this is a information which is not really required.
If you want to update it regulary, I would implement a column "rate", which gives you the value in comparison of Euro or US$ as example. This way people can get a better impression how much 1 Unit of the currency is worth.
Otherwise this looks to be quite okay.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
So I have this database:
John 4.2
Robert 6
Maria 3.2
What I would want is lets say I refresh a website. And in every refresh I will get a random name from that database based on the chance of showing-> that would mean that Robert would appear more times than the other people(because of his chance)
Any way to do this? I just can't think of anything.
I've create your table with columns name and weight.
The following request return on name, depending on the weight:
SELECT name FROM table ORDER BY RAND()*weight DESC LIMIT 1;
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have this value in my mysql table called item.Item is a column name, I want to get the values present in between two date values using query. How to get that.
eg. i want from 2017-2-6 to 2017-02-07 values.
Please guide me. Its a string value
2017-02-06_CHAWAL,2017-02-07_RAJMA,2017-02-08_ROTI,2017-02-09_BENGAN MASALA,2017-02-10_DAAL
You need to have separate table column with date. So you need to split this 2017-02-06_CHAWAL to
| date | name |
| 2017-02-06 | chawal |
Then you, can use between:
SELECT * FROM table WHERE date BETWEEN '2017-02-05' AND '2017-02-07'
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have land buy/sell related website. So I want to store land area units in India and their conversion in other in units in mysql table. When user from specific area see properties list on website and if he selects acre in dropdown list then he can see the every property area in the acre though the property was listed in another unit.
So How Do I do this??
A simple two table can do this .. if you like..
Table 1:Units[id,UnitName]
Table 2:ConversionUnit[conversionId,fromUnitId,toUnitId,offset]
such as
table 1: [1,Centimetre],[2,Mitre],[3,kilometre]
table 2: [1,1,2,100],[1,3,1,0.000001]
First entry in the table to for converting CM to M and second row is to convert from KM to CM.
Hope it helps..
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Say I have a MySQL table like the one below with a list of names in an organisation, and IDs for each.
id name
1 John Doe
2 Richard Smith
3 Jane Market
... ...
Given user will query for the person's first and/or last name (with the possibility of typos and nicknames used) and php should return the closest match to their query.
For example, if a user enters "ricky" (nickname for Richard), it should return the ID for Richard Smith.
For nicknames, you have to create a separate MySQL table, with lookups (Many-to-One relationship).
For typos, you will have to loop all of your names and compare them to what the user has entered using the levenshtein function, or the similar_text function. The User Contributed Notes will help.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a voting table called product_reviews, with a field that is ENUM from 1 to 5 called rating.
I want to get average rating from all rows with product_id 1665. I am using a star rating system so the average cannot be with decimals. Must be a number from 1 to 5.
Thank you very much.
SELECT round(avg(rating)) as average_review,
count(rating) as number_of_reviews
FROM product_reviews
WHERE product_id = 1665
You need to use round here since avg will return a value between 1.0 and 5.0, and if you use floor or ceil you're effectively eliminating 1 or 5 from the possible results unless all reviews on the product have that score.
Also, you'll alienate your users if they can openly see a product got 50 reviews with 1 star, and 1 review with 2 stars, and you're showing an average score of 2 stars next to that. It'll make your site seem unreliable which is usually not a good thing for a site that contains reviews. For this reason most star rating systems are also capable of showing partial stars to make it more precise.