I just need to know how I would place more table columns in this query, like major
ect.
Thank you!
MySqlDataAdapter adap = new MySqlDataAdapter(@"SELECT * FROM student", conn);
MySqlCommandBuilder sqlCmd = new MySqlCommandBuilder(adap);
DataSet sqlSet = new DataSet();
adap.Fill(sqlSet, "studentNumber");
conn.Close();
return sqlSet;
EDIT:
I think I asked the question wrong, I dont want entries from another table..I need the following.
I have a table called student
, in this table I have 4 columns, one of them being studentNumber
another being major
another gradePointAverage
. How to I add these columns into the code above?
EDIT NUMBER 2:
I know how to do the SELECT statement, I was more looking for help on this section adap.Fill(sqlSet, "studentNumber");
How do I put the major
column into that?
使用以下查询
select students.*,table2.major from student inner join table2 on student.it = table2.id
you can specify the columns names as below
"SELECT studentNumber,major FROM student"
since you have *
that means select all the columns, your code will return all the table columns
您可以使用联接查询来选择更多列,但前提是下面两个表中的列名称相同时才是查询SELECT t1.column AS column1,t2.column AS column2 FROM table1 AS t1 LEFT JOIN table2 AS t2 ON t1.column = t2 。柱
I have a table called student, in this table I have 4 columns, one of them being studentNumber another being major another gradePointAverage. How to I add these columns into the code above?
So select your columns in your query.
Change
MySqlDataAdapter adap = new MySqlDataAdapter(@"SELECT * FROM student", conn);
to
MySqlDataAdapter adap = new MySqlDataAdapter(@"SELECT studentNumber, major FROM student", conn);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.