473,790 Members | 3,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help in creating Table View

5 New Member
I had a table called 'FruitSaleList' , that contains the following columns

sl.no, shop_id, fruitName, price, ....

I had also another table called 'FruitList' that contains the columns

shop_id, fruitName, salesManId, ....

the problem is 'FruitList' table doesn't contain a column like fruitId.

Let us assume there are following fruits are available in all shops

Apple
Banana
Cherry
Dates
Elderberry
Figs
Grapes
Jackfruit
Orange
(it is a lengthy list, around 50)

In some case I need to list the details of fruits after 'Grapes' from 'FruitSaleList' . That means I have to list the 'Jackfruit' and 'Orange' from 'FruitSaleList' .

I'm struggling to list these using a MySQL query in php.

If I create a table view(FruitDetai ls) like below then I will proceed as specified below

|FruitId|FruitN ame|
|1 |Apple |
|2 |Banana |
|3 |Cherry |
|4 |Dates |
|5 |Elderberry|
|6 |Figs |
|7 |Grapes |
|8 |Jackfruit |
|9 |Orange |

If it is possible then I will proceed by selecting the fruits after the fruitId 7. I can create virtual column or table but should avoid creating or alter table with real column or table.

If I haven't explained clearly, please let me know so that I will explain even more.

any help is appreciated. thanks in advance for your help.
Feb 13 '09 #1
2 2082
Atli
5,058 Recognized Expert Expert
Hi.

So, your "FruitList" table is the one that actually lists the available fruits, and the "FruitSaleL ist" is the one that logs each fruit that is sold?

What is the Primary Key in the "FruitList" table? The name of the fruit?
If so, you should consider adding a integer ID field and use that as a PK instead. Using strings as PKs and FKs can get very messy and eat up a lot more recourses than is needed.

If you simply want to select items after a given value in alphabetical order, you could simply do:
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM `FruitList`
  2. WHERE `FruitName` > 'Grapes'
If the `FruitList` column is a string, this should give you every entry in the table that would be alphabetically sorted after 'Grapes'.

Is this what you are trying to do?
Feb 13 '09 #2
bthalapathi
5 New Member
Thanks for helping me! Atli.

First I will answer, your questions,

[Atli.] your "FruitList" table is the one that actually lists the available fruits, and the "FruitSaleL ist" is the one that logs each fruit that is sold?

[thala] Absolutely, you are correct. "FruitList" is the table having unique fruits. Sales logs are available in "FruitSaleL ist" table.

[Atli.] What is the Primary Key in the "FruitList" table? The name of the fruit?

[thala] Yes, fruitName is the Primary Key. It's my bad time to have this.
-------------------------------
For explanation purpose, I have listed the fruits in alphabetical order. Actually it will not be in alphabetical. But when we query the FruitList table, it will list the fruits in alphabetical order. Hence, I hope, I can solve this problem using your precious idea\help.

Currently, I'm out of reach of MyDesktop, once I back to my work, I'll update the status soon.

Still, I have a doubt,
Is it possible or Is there a anyway to create table VIEW as FruitDetails as i explained in my post.

Atli, Thanks Once again for your help

thala.
Feb 14 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
908
by: Keith | last post by:
I am having a problem creating a many-to-many-to-many type relationship. It works fine, but when I create a view to query it and test it, it does not generate the results I expected. Below if the DDL for the tables and the SQL for the view.
9
2939
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with a device. The definition of the table is as follows: CREATE TABLE devicedata ( device_id int NOT NULL REFERENCES devices(id), -- id in the device
9
4357
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my predecessor, I hasten to add) so that each day it creates a copy of the record for each company, changes the date to today's date, and prompts the user for any changes of ratings on that day. The resulting data table grows by approx 600 records per...
1
2055
by: AvrilComplic8ed | last post by:
Hello there I wonder if you can help me. I am creating a loans system for a make-believe CD rental company, in Microsoft Access. I have 3 tables: CD details, Member Details, and Loan Details. I have created forms for each, so the user of the system can view member details, enter new members, view loan details, enter new loans, etc. A main menu has also been created so the user can easily access the three forms from this page. However,...
1
4328
by: Julia | last post by:
Hello there. I have a question somewhat related to this topic, and I don't know where else to go. I hope somebody can help. I've created a database in access, that I'd like to share with less than 10 users. I'd like each user to see only some of the records in the database. So for example, if I have eight users in eight countries, I want each of them to only see information for their country. I was told that the easiest way to do...
2
2913
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to avoid the problem by avoiding the table control or resorting to databound controls that better manage state for me. I hope to understand how to solve the problem by using the Table web control and sticking to the approach of building the table at run...
13
13352
by: Nagib Abi Fadel | last post by:
Is it possible to create a session variable for each user in Postresql ?? Thx
0
5576
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
8
5118
by: Sham | last post by:
I am trying to perform the following query on a table that has been indexed using Full Text Search. The table contains multiple columns than have been indexed. (Below, all xml columns are indexed). dbo.maintable(ProfileID int pk) dbo.fts_table(ProfileID int pk fk, col1 xml, col2 xml, col3 xml) I want to perform a query that will return any rows that contain ‘x’ and ‘y’ in any columns. I.e. ‘x’ could be in col1 and ‘y’ could be in
0
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10419
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10147
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9987
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6770
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5424
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3709
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.