Is there a way I could create a variable that belongs to a table much like a static variable belongs to a class? So it "thing=1, person=2" were variables belonging to the table structure (not each row), then I could do something like this:

SELECT *
FROM table
WHERE type = table.thing OR type = table.person

I haven't touched sql in months, and I have a feeling this is something very simple.

I think I understand the functionality you are looking for. If not, I apologize now.
I've never seen anything like you described. This functionality is usually accomplished using what are commonly referred to as "Lookup Tables". A Lookup Table is usually a relatively small table with usually just 2 columns: an ID and a Name string. For example:

Manufacturer
===================
manufacturer_id BIGINT
manufacturer_name VARCHAR(50)

This table may contain data such as:

manufacturer_id manufacturer
=========================
1		Acura
2		Chevy
3		Ford
4		Honda
5		Toyota

Then your "car" table may look like this:

car_id manufacturer_id model_id year mileage color
================================================
1	 3		 2	 2004 24350 green
2	 3		 9	 2002 56771 black
3	 1		 34	 1999 78200 silver

See? Your car table uses the manufacturer_id instead of spelling out the manufacturer for every row. This is because, eventually your car table may have hundreds of thousands of rows, so why waste space inserting the manufacturer names in every row when there are only a handful of manufacturers.

So when you query, you do something like this:

SELECT manf.manufacturer_name
,mod.model_name
,c.year
,c.mileage
,c.color
FROM car c
INNER JOIN manufacturer manf ON c.manufacturer_id = manf.manufacturer_id 
INNER JOIN model mod ON c.model_id = mod.model_name
WHERE mileage < 50000
ORDER BY year DESC

This help?

I understand what you said, its how I ended up doing it anyway. I'm just used to thinking more along the lines of OOP (classes). Stupid Java!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.