c# - Create a number for each different field of a table -
suppose have table of cars. have brand column, , column model. marks can repeated. , query shows me mark in 1 column, column in model, , in column generate number each car brand, has move up. in following example show how should result of query.
brand model brand number --------------- ----------------------- --------------------- ford ranger 1 ford f100 1 ford explorer 1 chevrolet silverado 2 chevrolet luv 2 mitsubishi l200 3 toyota hilux 4 could tell me how generate number each mark in query?
if there's many-to-one relationship between model , make should in separate tables. this:
id | name --------- 1 | ford 2 | chevrolet 3 | mitsubishi 4 | toyota id | makeid | name ------------------- 1 | 1 | ranger 2 | 1 | f100 3 | 1 | explorer 4 | 2 | silverado 5 | 2 | luv 6 | 3 | l200 7 | 4 | hilux then query simple select statement joins 2 tables:
select make.name brand, model.name model, make.id number make inner join model on make.id = model.makeid
Comments
Post a Comment